Validate email with jQuery

后端 未结 3 2065
长情又很酷
长情又很酷 2020-12-12 01:34

I have input name=\"email\" and a button on the page.

How do I validate this input in live for a valid email address? And add some class fo

3条回答
  •  半阙折子戏
    2020-12-12 02:08

    $('#email').bind('keyup', function(){
        if(this.value.test([REGULAR_EXPRESSION])
            //doStuff -- add active class
        else
            //doOtherStuff -- add inactive class
    });
    

    replace [REGULAR_EXPRESSION] with one of the regular expressions found here: http://www.regular-expressions.info/email.html

提交回复
热议问题