if(crmForm.all.emailaddress1!=null && crmForm.all.emailaddress1.DataValue!=null)
{
var isval = validateEmail(crmForm.all.emailaddress1.DataValue);
if(isval==false){
event.returnValue = false;
crmForm.all.emailaddress1.DataValue = null;
return false;}
}
if(crmForm.all.emailaddress2!=null && crmForm.all.emailaddress2.DataValue!=null)
{
isval = validateEmail(crmForm.all.emailaddress2.DataValue);
if(isval==false){
event.returnValue = false;
crmForm.all.emailaddress2.DataValue = null;
return false;}
}
if(crmForm.all.emailaddress3!=null && crmForm.all.emailaddress3.DataValue!=null)
{
isval = validateEmail(crmForm.all.emailaddress3.DataValue);
if(isval==false){
event.returnValue = false;
crmForm.all.emailaddress3.DataValue = null;
return false;}
}
function validateEmail(mailstring)
{
var searchStr='@';
var isEmail = mailstring.indexOf(searchStr);
var searchStr2 = '.';
var isValid = mailstring.lastIndexOf(searchStr2);
if(isEmail == '-1' || isValid == '-1' || (isValid < isEmail) || (isValid == (mailstring.length-1)) || (isValid > (mailstring.length-3)))
{
alert('Please enter proper email address');
return false;
}
}
No comments:
Post a Comment