how to allow comma separated email id textbox input in javascript

function validemailcommaseparated()
{
        var emailexp = new RegExp(/^([\w+-.%]+@[\w-.]+\.[A-Za-z]{2,4},?)+$/i);
        var emailtxt = $('#txtmail').val();
        if (!emailexp.test(emailtxt)) {
            alert("you have entered an invalid email address!");
            $('#txtmail').val(emailtxt.substring(0, emailtxt.lastIndexOf(',')));
            return false;
        }
        else {
            return true;
        }
    }


<!-- call function : onchange = "return validemailcommaseparated();" -->

Post a Comment

0 Comments