Email validation using jQuery

后端 未结 30 2382
被撕碎了的回忆
被撕碎了的回忆 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:17

    This performs a more thorough validation, for example it checks against successive dots in the username such as john..doe@example.com

    function isValidEmail(email)
    {
        return /^[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,4}$/.test(email)
            && /^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*/.test(email);
    }
    

    See validate email address using regular expression in JavaScript.

提交回复
热议问题