Block existing email in jquery.validate

Asked

Viewed 66 times

2

I have a registration form that uses the jquery.validate.js plugin http://jqueryvalidation.org. I searched but couldn’t find a way to return an error when the client inserts an already valid email. What is the best alternative to solve my problem? Thanks in advance.

  • You can create custom validations and messages. How is this check? Ajax ?

  • Could be, just want using the same plugin, and enjoy the same error message structure.

1 answer

3

Validator has a property called remote which may be used in your case:

$( "#myform" ).validate({
  rules: {
    email: {
      required: true,
      email: true,
      remote: {
        url: "check-email.php",
        type: "post",
        data: {
          email: function() {
            return $("#email").val();
          }
        }
      }
    }
  }
});

The result of the request (made for the file check-email.php) must be true or false.

Source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.