3

I am trying to use ASP MVC 2 data annotations to validate a semicolon delimited list of email addresses on the client side. The regex below works on the server side but doesn't work with the javascript because javascript regular expressions don't support conditionals.

^([A-Za-z0-9_\\+\\-]+(\\.[A-Za-z0-9_\\+\\-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*\\.([A-Za-z]{2,4})(?(?=.);[ ]*|))+$

Is there a way to require that the email address is followed by a semicolon only if it is followed by another email address without using a conditional? Thanks.

1
  • TLDs can be longer than 4 characters. Commented Apr 13, 2012 at 16:14

1 Answer 1

2

if you need only this to alow this -

[email protected]; [email protected]

then regexp is

"^(([A-Za-z0-9_\+\-]+\.)*[A-Za-z0-9_\+\-]+@([A-Za-z0-9]+\.)+([A-Za-z]{2,4})(\s*(;)\s*))*([A-Za-z0-9_\+\-]+\.)*[A-Za-z0-9_\+\-]+@([A-Za-z0-9]+\.)+([A-Za-z]{2,4})$"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.