
March 19th, 2012, 09:39 PM
|
|
Registered User
|
|
Join Date: Mar 2012
Posts: 1
Time spent in forums: 36 sec
Reputation Power: 0
|
|
|
JavaScript - Multiple email validation
After a quick research, I wasn't able to find any solution for the multiple email validation using regex (split JS function is not applicable, but some reason back-end of the application waits for a string with emails separated by `;`).
Here are the requirements:
1. Emails should be validated using the following rule: `[A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4}`
2. Regex should accept `;` sign as a separator
3. Emails can be written on multiple lines, finishing with `;`
4. Regex may accept the end of the line as `;`
I come up with this solution:
<pre>
^[A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4}(?:[;][A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4}?)*
</pre>
but it doesn't work for point #3-4
All sort of help will be appreciated
|