I thought this would be really simple, but i'm stumped. I'd like to validate some data without submitting the form, but i can't seem to get the focus to go back to the field with the bad data. I've stripped out most of the code just to illustrate the problem. In both IE and Mozilla, the focus still goes to the next element. This is .php generated.
<html><body><script type="text/javascript">
var numAdults=5;
var numChildren=0;
function Check(element){
value=parseInt(element.value);
if(isNaN(value) || value<0 || value>99){
if(element.name=='txtNumAdults'){
element.value=numAdults;
}else{
element.value=numChildren;
}
element.focus();
return false;
}else{
//SetDirty(element);
return true;
}
}
</script>
<form action="a1.php" method="POST" name="myFrm">
<table>
<tr><td align="right"><label>Adults:</label></td>
<td><input type="text" name="txtNumAdults" size="3" value="5" onChange="Check(this);" /></td></tr>
<tr><td align="right"><label>Children:</label></td>
<td><input type="text" name="txtNumChildren" size="3" value="0" onChange="Check(this);" /></td></tr>
</table></form></body></html>