Email validation using jQuery

后端 未结 30 2342
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 16:52

I\'m new to jQuery and was wondering how to use it to validate email addresses.

30条回答
  •  无人共我
    2020-11-22 17:35

    A simplified one I've just made, does what I need it to. Have limited it to just alphanumeric, period, underscore and @.

    
    function testEmailChars(el){
        var email = $(el).val();
        if ( /^[a-zA-Z0-9_@.-]+$/.test(email)==true ){
            $("#a").html("valid");
        } else {
            $("#a").html("not valid");
        }
    }
    

    Made with help from others

提交回复
热议问题