Javascript regex to check email list using ASP MVC 2 annotations

I am trying to use ASP MVC 2 data annotations to check a client-side comma separated list of email addresses. The regular expression below works on the server side, but does not work with javascript, because javascript regular expressions do not support conventions.

^([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 an e-mail address is followed by a semicolon only if it is followed by a different e-mail address without using a conditional expression? Thank.

+3
source share
1 answer

if you need it just for this -

foo@bar.cz; bar@foo.cz

regexp

"^(([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})$"
+2

Source: https://habr.com/ru/post/1762560/


All Articles