Monday, May 28, 2012

Email Validation Script in Siebel

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;
    }
}

2 comments :

  1. /((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*(\s*(;|,)\s*|\s*$)*)*/;
    modified it to work with multiple email address. will show error message when there is a space between 2email address as well.

    ReplyDelete