Block existing email in jquery.validate

2

I have a registration form that uses the jquery.validate.js link plugin. I researched but did not 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.

    
asked by anonymous 27.08.2015 / 15:50

1 answer

3

Validator has a property called remote that can 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 to the check-email.php file) must be true or false .

Font .

    
27.08.2015 / 18:54