PatrickIRL
Programmer
- Jun 25, 2003
- 383
Hi,
I have an HTML page with some fields that require validation. What I am doing is on the onblur() event I'm validating the field. If there is invalid data I want the focus to stay on that field. This is working fine in IE but not Netscape or Mozilla. As a test I produced the following, can anybody shed some light on the subject?
<html>
<head>
<script language="javascript">
function validateDobDay(){
if(document.getElementById("dobDD"
.value < 10){
alert("Please enter a value greater than 10."
;
document.getElementById("dobDD"
.value="";
document.getElementById("dobDD"
.focus();
return false;
}
}
</script>
</head>
<body>
<input type="text" id="dobDD" size="2" onblur="validateDobDay()">
<input type="text" id="dobMM" size="2">
</body>
</html>
Thanx in advance ....

I have an HTML page with some fields that require validation. What I am doing is on the onblur() event I'm validating the field. If there is invalid data I want the focus to stay on that field. This is working fine in IE but not Netscape or Mozilla. As a test I produced the following, can anybody shed some light on the subject?
<html>
<head>
<script language="javascript">
function validateDobDay(){
if(document.getElementById("dobDD"
alert("Please enter a value greater than 10."
document.getElementById("dobDD"
document.getElementById("dobDD"
return false;
}
}
</script>
</head>
<body>
<input type="text" id="dobDD" size="2" onblur="validateDobDay()">
<input type="text" id="dobMM" size="2">
</body>
</html>
Thanx in advance ....