Skip to content Skip to sidebar Skip to footer

RegEx Of Email Address With Additional Domains With JQuery Vaildate

I need to validate an email address with extra domains. I validate currently a normal email with @email.com, but I need to validate an email that has @email.email.com. I am not f

Solution 1:

To match any (usual) email with a two part top-level-domain, like *@google.co.uk you could use a RegExp, that matches 2-3 word parts in the domain section:

var emailRegExp = /[a-zA-Z0-9._-]@[a-zA-Z0-9-]+\.\w+(\.\w+)?/
...
// in your code
matches: emailRegExp

The RegExp explained:

  • The name part [a-zA-Z0-9._-] will match any usual characters, as well as ., _ and -

  • The domain name part [a-zA-Z0-9-] is about the same as the name, but without . or _

  • The top-level-domain part \.\w+(\.\w+)? will match any single tld like .com, .net, etc. as well as the double ones .co.uk, .co.jp, .foo.bar

The RegExp is a quite short one. If you are really interested in the correct email verification you should take a look at the RFC822-Spec (SCNR :D)


Solution 2:

This worked for jquery validate to validate that email belongs to the organization. I was really close, but I didn't think it would need a few things.

(.+@+[A-Za-z0-9._-]+\\.email.com$)|(.+@email.com$)

Post a Comment for "RegEx Of Email Address With Additional Domains With JQuery Vaildate"