Forum Moderators: open

Message Too Old, No Replies

Email Validation RegExp Question

Need some advice on how to block email from a specific domain

         

pmmenneg

5:21 am on Oct 16, 2009 (gmt 0)

10+ Year Member



Hi there. Using JS to do some client-side validation of email, and have a regular expression that seems to be pretty tight in terms of what it validates, etc:

^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*)\.(([0-9]{1,3})¦([a-zA-Z]{2,3})¦(aero¦coop¦info¦museum¦name))$

The only addition that I'd like to make is that I'd like to deny any email that is from the example.(com¦org¦net¦etc...) domain to false as well. Have tried modifying the above, but just can't get it to work no matter what I do. Using this tool to test it:

[regular-expressions.info...]

Any advice?

Thanks,

Paul

rainborick

3:28 pm on Oct 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah. Use two separate tests. Don't make yourself crazy trying to craft a single, perfect regular expression. You can combine them both into a single function, and/or make the second test optional if you need the function to work with more than one page or form.

Get the code up and running today, and you can work on a more elegant solution at your own pace.

pmmenneg

9:42 pm on Oct 19, 2009 (gmt 0)

10+ Year Member



Used two seperate tests as described, thanks for the tip!