I have a multiline textbox in which i will be entering many email addresses. how to validate email address at client side for multiple email address. i have used RegularExpressionValidator for validating email in textbox.
thank you
Simply extend the Validator with a loop. Split the textbox string into a array of emails and validate each. In that loop you can feed another array to later screen all wrong emails or abort at the first failed validation.
Something like this:
var mails = textboxcontent.split(';'); // you can also split by blanks. You may also consider the use of trim(str) -> see example below
for(var i = 0, len = mails.length; i < len; i++){
// check mails[i]
if(false)
alert();
}
// or
var failed = '';
for(var i = 0, len = mails.length; i < len; i++){
// check mails[i]
if(false)
failed += mails[i] + ' ';
}
Custom trim implementation (jQuery has a own one if you use it)
function trim (str) {
return str.replace (/^\s+/, '').replace (/\s+$/, '');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With