[RESOLVED]How to implement email validation on multiple email address in a single text box

Hi,

I have a text box that works similar to cc text box in Outlook or other email providers. All i want to implement email validator on that text box to check if all the email addresses have been properly entered or not.

One more thing I want to do is to store those email addresses in a table with one email in each row not all of them in single row.

Regards,

Shashikant

hi

shashikant

All i want to implement email validator on that text box to check if all the email addresses have been properly entered or not.:for this u can use regex ill be a good idea

for eg

(.*?)++(.*?)@gmail.com

should work.for gmail

love4asp.net

hi
shashikant
All i want to implement email validator on that text box to check if all the email addresses have been properly entered or not.:for this u can use regex ill be a good idea
for eg
(.*?)++(.*?)@gmail.com

should work.for gmail

I want to validate any email address of any provider. So I this will not work for me.

try this

$emails = preg_split('[,|;]',$_POST['emails']);
foreach($emails as $e){
    if(preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/',trim($e)) == 0){
        echo($e ."is not a valid email address");
    }
}

or u can try like this..just a eg for u

Syntax for Regular Expression Validator

<asp:TextBox ID="txtEmailID" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="revEmailID" runat="server"
ControlToValidate="txtEmailID"
ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*">*</asp:RegularExpressionValidator> 

<html>
<body>
<script language="javascript">
function checkEmail(email) {
var regExp = /(^[a-z]([a-z_.]*)@([a-z_.]*)([.][a-z]{3})$)|(^[a-z]([a-z_.]*)@([a-z_.]*)(.[a-z]{3})(.[a-z]{2})*$)/i;
return regExp.test(email);
}
 
function checkEmails(){
    var emails = document.getElementById("emails").value;
    var emailArray = emails.split(",");
    var invEmails = "";
    for(i = 0; i <= (emailArray.length - 1); i++){
        if(checkEmail(emailArray[i])){
            //Do what ever with the email.
        }else{
            invEmails += emailArray[i] + "n";
        }
    }
    if(invEmails != ""){
        alert("Invalid emails:n" + invEmails);
    }

}
</script>
 
<input name="emails" id="emails" type="text" size="50" /><br />
<a href=javascript:checkEmails();>GO</a>
</body>
</html>

webcodeexpert

Read the article to solve your problem

jQuery to Validate email address using RegularExpression in asp.net

I have got an easy solution for this:

Here is it:

<asp:RegularExpressionValidator ID="RegularExpressionValidator" runat="server" ControlToValidate="txt_email"
                                    Display="Dynamic" ErrorMessage="<br />Please enter valid emails." ValidationExpression="w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*([;]s*w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*)*"
                                    ValidationGroup="_stock" ForeColor="Red"></asp:RegularExpressionValidator>

Leave a Reply