AnsweredAssumed Answered

eMail Validation Code Problem

Question asked by ArtL on Oct 9, 2013
Latest reply on Oct 10, 2013 by ArtL

Title

eMail Validation Code Problem

Post

     I have an issue with this email validation code (very cool script I found online and modified).  I have expanded it to look for .com, .ca, .net and .org as the only email extensions that will be accepted in the field.

     For some reason, it is taking the first entry in the inclusion and saying it is not valid.  In the code below, the extension it will not allow is ".ca"

      and Right (_email;2)="ca"

     If the abvove code was ".com", my warning message would read that .com was incorrect.  Etc Etc.

     Can anyone tell me why this is the case? 

      

     Thank you in advance for your help!

      

     IsEmpty (Email) or
     Let ([
             _alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
             _email = Trim (Email);
             _posAt = Position (_email;"@";1;1)
     ];
             Filter (_email;_alphanum & "_-@.!#$%&^'*+-{|}~")=_email           

             and PatternCount (_email;"@")=1
             and PatternCount (_email;".com")=1
             and PatternCount (_email;".ca")=1
             and PatternCount (_email;".net")=1
             and PatternCount (_email;".org")=1
             and IsEmpty (Filter (Left(_email;1);"@"))
             and IsEmpty (Filter (Left(_email;1) & Middle (_email; _posAt -1;3) & Right (_email;1);"."))
             and not Position (_email;"..";1;1)
             and Position (_email;".";_posAt +2;1)
             and Right (_email;2)="ca" or Right (_email;3)="net" or Right (_email;3)="org" or Right (_email;3)="com"
             and not IsEmpty (_email)
     )

Outcomes