user1995781 user1995781 - 3 months ago 60
jQuery Question

jQuery Validate Remote Error Message

I am using jquery validation plugin (http://jqueryvalidation.org/) for form validation. There is a field I want to do remote validate.

Example code:

$( "#myform" ).validate({
rules: {
email: {
required: true,
email: true,
remote: "check-email.php"
}
}
});


When it is not valid, it display "Please fix this field." How can I have custom error message for the remote validate such as "Email address already in used. Please use other email."?

Thank you.

Answer

their documentation seems to show a message option. can that be helpful ?

http://jqueryvalidation.org/validate

example on their site:

$(".selector").validate({
  rules: {
    name: "required",
    email: {
      required: true,
      email: true
    }
  },
  messages: {
    name: "Please specify your name",
    email: {
      required: "We need your email address to contact you",
      email: "Your email address must be in the format of name@domain.com"
    }
  }
});
Comments