Html code for email validiation
<html>
<head>
<script>
function validate(form_id,email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;//alert(reg.test(address));
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}
}
</script>
</head>
<body>
<form id="form_id" method="post" action="action.php" onSubmit="javascript:return validate('form_id','email');">
<input type="text" id="email" name="email" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
<head>
<script>
function validate(form_id,email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;//alert(reg.test(address));
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}
}
</script>
</head>
<body>
<form id="form_id" method="post" action="action.php" onSubmit="javascript:return validate('form_id','email');">
<input type="text" id="email" name="email" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Comments
Post a Comment