« Mortgage Calculator | Main | JQuery $.get() caching in IE 7 »
April 23, 2010
Email address regex
This fails for paul,hollands@thingmail.com as it still matches on a substring hollands@thingmail.com:
onblur="if(/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/
.match(this.value)){ var blah = ''; } else { poppy('Your email address appears to be invalid.'); this.value = ''; }"
This fixes the issue.
onblur="if(/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/
.exec(this.value) == this.value){ var blah = ''; } else { poppy('Your email address appears to be invalid.'); this.value = ''; }"
Posted by pj at April 23, 2010 10:50 AM