Hi
I have a text field, and i need to validate it.
I want to return focus back to it if the value entered
is not numeric. I do this by capturing the onblur event
and calling the validate function.
It works well on IE but for some reason doesnot work
on Netscape 6.2.1
Any suggestions.
====
<HTML>
<HEAD>
<TITLE>Validate</TITLE>
<script language="JavaScript">
function validate()
{
var val = document.testForm.txt1.value;
if(val == 1) {
return true;
}
alert('dont submit');
return false;
}
function validatetxt1()
{
var val = document.testForm.txt1.value;
if(val == 1) {
return true;
}
alert('invalid values');
return false;
}
</script>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="result.html" NAME ="testForm" >
<INPUT TYPE="text" NAME="txt1" onChange="return validatetxt1();">
<INPUT TYPE="text" NAME="txt2"
onBlur = "if(txt2.value=='2'){
alert('onblur');return true;
}else{
alert('returning false BLUR');return false;
}">
<INPUT TYPE="text" NAME="txt3" >
<input type="submit" onClick="return validate();">
</FORM>
</BODY>
</HTML>
====
Somehow the onchange/onblur function does not return false