Hi. 2 u
Could u tell me plz what’s wrong with my following code. I’d like to validate my HTML fields field by field. So, I can’t leave the first textbox unless it has been validated. My code allows me to submit empty fields. What’s wrong?
Any help is appreciated
<html>
<head>
<script language="JavaScript">
function isEmpty(fieldname){
if (fieldname.value== null || fieldname.value == ""){
alert("fill in the box please!")
fieldname.focus();
return false;
} else {
return true;
}
}
</script>
</head>
<body>
<form name="form1" method="GET" action="????????" >
<p> User Name: <input type="text" name="txt1" onBlur="isEmpty(this)" />
<p>Password: <input type="password" name="txt2" onBlur="isEmpty(this)" />
<p>Email: <input type="text" name="txt3" onBlur="isEmpty(this)" />
<br />
<input type="submit" VALUE="SUBMIT" />
</form>
</body>
</html>