function BusComp_PreWriteRecord ()
{
try
{
this.ActivateField("Email Address");
if (this.GetFieldValue("Email Address") != "")
{
var sEmail = this.GetFieldValue("Email Address");
var sPattern = /((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([, ])*)*/;
var isValid = sEmail.replace(sPattern,"Y");
if(isValid != "Y")
{
TheApplication().RaiseErrorText("Please enter a valid email address");
return (CancelOperation);
}
else
return (ContinueOperation);
}
else
return (ContinueOperation);
}
catch (e)
{
throw (e);
}
finally
{
sEmail = null;
sPattern = null;
isValid = null;
}
}
{
try
{
this.ActivateField("Email Address");
if (this.GetFieldValue("Email Address") != "")
{
var sEmail = this.GetFieldValue("Email Address");
var sPattern = /((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([, ])*)*/;
var isValid = sEmail.replace(sPattern,"Y");
if(isValid != "Y")
{
TheApplication().RaiseErrorText("Please enter a valid email address");
return (CancelOperation);
}
else
return (ContinueOperation);
}
else
return (ContinueOperation);
}
catch (e)
{
throw (e);
}
finally
{
sEmail = null;
sPattern = null;
isValid = null;
}
}
/((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*(\s*(;|,)\s*|\s*$)*)*/;
ReplyDeletemodified it to work with multiple email address. will show error message when there is a space between 2email address as well.
Really very fantastic idea.
ReplyDelete