PDA

View Full Version : Multiple emails validation in one text box with comma



giselle2008
02-06-2008, 09:23 AM
hi there..i need some help on this email validation. i got a text box, can let the users to input many email with the seprator comma(,) or this (. then how can i use the javascxript to do a validation for it? plz help..i duno how to code it. plz help on code.thanx alot

jscheuer1
02-06-2008, 06:10 PM
You cannot use a (.) to separate email addresses because at least one (.) usually appears in an email address and more than one can as well.

Email validation is best left to the server side, which would depend upon which server side language and mail routines you are using. Any javascript email validation would be just a 'front end' for that, and could be disabled by the user.

If you have a function to validate email addresses, it can be used with a comma delimited string by splitting the string into an array and applying it to each item in the array.

nirajdhiman
06-12-2009, 10:28 AM
Use this java script

and it is workink fine


<script language="JavaScript1.2">
var testresults

function checkemail()
{
//var str=document.validation.txtAnchorEmail.value
var str=document.getElementById('ctl00_ContentPlaceHolder1_txtAnchorEmail').value;
var filter=/^.+@.+\..{2,3}$/

if (filter.test(str))
testresults=true
else
{
alert("Please input a valid email address!")
testresults=false
}
return (testresults)
}
</script>



<script>
function checkbae(){
if (document.layers||document.all)
return checkemail()
else
return true
}
</script>





<asp:TextBox id="txtAnchorEmail" onBlur="return checkbae();" runat="server" CssClass="frm_input"></asp:TextBox