Email Validations in Java Script
<SCRIPT LANGUAGE="JavaScript">
function verify()
{
function validEmail(emailV) {
dotV = emailV.indexOf(".", emailV.length-4);
if (emailV.length < 6) return false;
if (emailV.indexOf("@") < 1) return false;
if (emailV.indexOf("@") > (emailV.length-4)) return false;
if (dotV == -1 || dotV > (emailV.length-3)) return false;
for (var i=0; i < emailV.length; i++) {
var tempV = emailV.substring(i, i+1)
if (tempV == " " || tempV == "'" || tempV == '"' || tempV == "," || tempV == ";" || tempV == "`" || tempV == "<" || tempV == ">") {
return false;
}
}
}
if (document.form1.name.value == "")
{
alert("Please Fill Your Name");
document.form1.name.focus();
return (false);
}
else if (document.form1.email.value=="")
{
alert('Please Enter Your Email address');
document.form1.email.focus();
return (false);
}
else if (validEmail(document.form1.email.value)==false)
{
alert('Please Enter a valid Email address');
document.form1.email.select();
return (false);
}
else if (document.form1.subject.value=="")
{
alert('Please Write Your Subject');
document.form1.subject.focus();
return (false);
}
else if (document.form1.msg.value=="")
{
alert('Please Type Your Messege or Query Here');
document.form1.msg.focus();
return (false);
}
else
{
alert('Are you sure want to Submit ?');
return (true);
}
}
function set(form)
{
document.form1.elements[0].focus();
}
</SCRIPT>
Comments
Post a Comment