jpkleemans / angular-validate

Painless form validation for AngularJS. Powered by the jQuery Validation Plugin.
MIT License
68 stars 33 forks source link

Unable to validate multiple email with input type email #24

Closed HarsharanSingh007 closed 6 years ago

HarsharanSingh007 commented 6 years ago

Hi Am trying to validate multiple email address but it's not accepting the external method what I've got from doing the research. Ref: http://jsfiddle.net/leniel/xFphm/7/

$validatorProvider.addMethod("multiemail", function (value, element) {
        if (this.optional(element)) {
            return true;
        }

        var emails = value.split(/[" "]+/); // spliting the email using space
        console.log(emails);
        valid = true;
        for (var i in emails) {
            value = emails[i];
            valid = valid && $validatorProvider.email.call(this, $.trim(value), element);
        }
        return valid;
    }, "Invalid Email address");

If I'll use the single email address then it will throw the below error: screenshot_10

If I'll add the multiple email address then it will throw the normal email validation error: screenshot_11

Please Help to resolve the issue/bug asap. Thanks in advance

jpkleemans commented 6 years ago

Hi, $validatorProvider.email does not exist. You can use the method from jQuery validate directly: jQuery.validator.methods.email (or $.validator.methods.email).