Email address validation issue

Posted in: Newspaper
Post count: 5

Hello

A user recently complained that she was unable to leave a comment because allegedly her email address was incorrect. The email address was something like e@example.net.

Upon investigation, it looks like the email validation regex requires at least two characters before the @ symbol:


// in tagdiv_theme.js (and the minified version):
// patern to check emails

email_pattern : /^[a-zA-Z0-9][a-zA-Z0-9_\.-]{0,}[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9_\.-]{0,}[a-z0-9][\.][a-z0-9]{2,4}$/

I believe a more sensible approach would be the following regex:


email_pattern : /^[a-zA-Z0-9][a-zA-Z0-9_\.-]*@[a-zA-Z0-9][a-zA-Z0-9_\.-]{0,}[a-z0-9][\.][a-z0-9]{2,4}$/

which requires that the email address starts with an alphanumeric character and then optionally allows the other valid characters.

Would be cool if this would get into the next version. Thanks!

  • This topic was modified 8 years by clawoo.
  • This topic was modified 8 years by clawoo.
  • This topic was modified 8 years by clawoo.
Viewing 1 post (of 1 total)
The forum ‘Newspaper’ is closed to new topics and replies.