Jump to content

E-mail Validation Advice


ProblemHelpPlease

Recommended Posts

I am currently using the script below to validate e-mail addresses but it has a problem in that it won't allow certain charaters that can be used in the local part of email addresses like +

if (!/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.createaccount.email.value)){alert("Not a valid e-mail address");return false;}

I'm still getting used to using all the aspects of regular expressions (anyone know of a good advanced tutorial) and am not sure how to add the + or any other charater into the script.

Link to comment
Share on other sites

I am partial to this site regarding regular expressions:http://www.regular-expressions.info/As to how to match a "+", just put it inside the character class "[]". You're already searching for letters and digits (\w) and hypens (-), so, if you want to add "+" into the mix, modify your character class from "[\w-]" to "[\w+-]".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...