function vail()
{
/*FUNCTION #2 NAME ENTRY CHECK START FROM HERE: This function is to check the Name field values*/	
if (trim(document.Contact.ContactName.value).length == 0)
{
alert("Enter your name in the Contact Name field.");
document.Contact.ContactName.focus();
return;
}
/*FUNCTION #2 NAME ENTRY CHECK END TILL HERE:*/
/*FUNCTION #1 TELEPHONE NUMBER CHECK START FROM HERE: This function is to check the Phone field values*/
if (document.Contact.Phone.value=="")
{
alert("Enter your Phone No. in the Phone field.");
document.Contact.Phone.focus();
return false;
}
else if(isNaN(document.Contact.Phone.value))
{
alert("Telephone no. has to numeric value only (0 to 9).");
document.Contact.Phone.focus();
return false;
}
/*FUNCTION #1 TELEPHONE NUMBER CHECK END TILL HERE:*/
/*FUNCTION #3 EMAIL ENTRY CHECK START FROM HERE: This function is to check the EMail field values*/	
else if (trim(document.Contact.EMail.value).length == 0)
{
alert("Please enter your E-mail Address in E-mail address field.");
document.Contact.EMail.focus();
return false;
}
else if (emailCheck(document.Contact.EMail.value) == false)
{
document.Contact.EMail.focus();
return false;
}
document.Contact.submit();
}
function ltrim (s)
{
return s.replace( /^\s*/, "" );
}
function rtrim (s)
{
return s.replace( /\s*$/, "" );
}
function trim (s)
{
return rtrim(ltrim(s));
}
function emailCheck(emailStr)
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) 
{
if (user.charCodeAt(i)>127) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
}
for (i=0; i<domain.length; i++) 
{
if (domain.charCodeAt(i)>127) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
}
if (user.match(userPat)==null) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) 
{
for (var i=1;i<=4;i++) 
{
if (IPArray[i]>255) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) 
{
if (domArr[i].search(atomPat)==-1) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
}
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
if (len<2) 
{
alert("E-mail address is not correct, Please provide active E-mail address only.");
return false;
}
return true;
}
/*FUNCTION #2 NAME ENTRY CHECK END TILL HERE:*/
