Html code for email validiation_1
<html><head>
<script>
function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<=1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
else
{
alert("valid email");
}
}
</script>
</head>
<body>
<form name="myForm" onSubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
*
</form>
</body>
<script>
function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<=1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
else
{
alert("valid email");
}
}
</script>
</head>
<body>
<form name="myForm" onSubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
*
</form>
</body>
Thanks for code. Currently i m looking for the email html validation code for my email related work. Now i can easily work through it.
ReplyDeleteU wlcm ........
Delete