validate email with regex jquery

前端 未结 5 756
名媛妹妹
名媛妹妹 2020-12-06 18:09

referring to this issue:

how can I set a minimum length for a field with jquery?

相关标签:
5条回答
  • 2020-12-06 18:41
    Email: {
                          group: '.col-sm-3',
                          enabled: false,
                          validators: {
                              //emailAddress: {
                              //    message: 'Email not Valid'
                              //},
                              regexp: {
                                  regexp: '^[^@\\s]+@([^@\\s]+\\.)+[^@\\s]+$',
                                  message: 'Email not Valid'
                              },
                          }
                      },
    
    0 讨论(0)
  • 2020-12-06 18:44

    This : /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i is not working for below Gmail case

    gmail.@gmail.com gmail@.gmail.com

    Below Regex will cover all the E-mail Points: I have tried the all Possible Points and my Test case get also pass because of below regex

    I found this Solution from this URL:

    Regex Solution link

    /(?:((?:[\w-]+(?:\.[\w-]+)*)@(?:(?:[\w-]+\.)*\w[\w-]{0,66})\.(?:[a-z]{2,6}(?:\.[a-z]{2})?));*)/g
    
    0 讨论(0)
  • 2020-12-06 18:55

    You probably want to use a regex like the one described here to check the format. When the form's submitted, run the following test on each field:

    var userinput = $(this).val();
    var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i
    
    if(!pattern.test(userinput))
    {
      alert('not a valid e-mail address');
    }​
    
    0 讨论(0)
  • 2020-12-06 18:58

    This regex can help you to check your email-address according to all the criteria which gmail.com used .

    var re = /^\w+([-+.'][^\s]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    
    var emailFormat = re.test($("#email").val());// this return result in boolean type
    
    if (emailFormat) {}
    
    0 讨论(0)
  • 2020-12-06 19:01
    function mailValidation(val) {
        var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    
        if (!expr.test(val)) {
            $('#errEmail').text('Please enter valid email.');
        }
        else {
            $('#errEmail').hide();
        }
    }
    
    0 讨论(0)
提交回复
热议问题