- If you want to get information from users and want to check each element (ie: user name, password, email) individually, and alert the user to correct the wrong input before moving on, you can use onBlur.
- For example:
<html>
<head>
<script>
function emailchk()
{
var x=document.feedback.email.value
if (x.indexOf("@")==-1)
{
alert("It seems you entered an invalid email address.")
document.feedback.email.focus()
}
}
</script>
</head>
<body>
<form name="feedback">
Email:
<input type="text" size="20" name="email" onblur="emailchk()">
<br>
Comment:
<textarea name="comment" rows="2" cols="20"></textarea>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html> - If you enter an email address without the @, you'll get an alert asking you to re-enter the data.
onBlur()
Subscribe to:
Post Comments
(
Atom
)
0 comments :
Post a Comment