That said, there are a few basic checks that can help make sure that you're getting something reasonable.Some things to improve: Instead of new Reg Exp, just try writing the regexp out like this: Here is a very good discussion about using regular expressions to validate email addresses; "Comparing E-mail Address Validating Regular Expressions" Here is the current top expression, that is Java Script compatible, for reference purposes: /^[-a-z0-9~! ] )*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_] )*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]\.[0-9]\.[0-9]\.[0-9]))(:[0-9])? $/i My knowledge of regular expressions is not that good.But what if I told you there were a way to determine whether or not an email is valid without resorting to regular expressions at all? The activation email is a practice that’s been in use for years, but it’s often paired with complex validations that the email is formatted correctly.
If you actually check the Google query I linked above, people have been writing (or trying to write) RFC-compliant regular expressions to parse email addresses for years.Here's an example of the above in action: Almost all answers to this questions suggest using Regex to validate emails addresses.I think Regex is only good for a rudimentary validation.If the data entered by a client was incorrect or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information.This was really a lengthy process which used to put a lot of burden on the server.Java Script provides a way to validate form's data on the client's computer before sending it to the web server. First let us see how to do a basic form validation.In the above form, we are calling validate() to validate data when onsubmit event is occurring.The following example shows how to validate an entered email address.An email address must contain at least a ‘@’ sign and a dot (.).Think about it this way: I register for your website under the email address . That’s probably going to bounce off of the illustrious mail daemon, but the formatting is fine; it’s a valid email address.To fix this problem, you implement an activation system where, after registering, I am sent an email with a link I must click.