Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 226
user1995781 Avatar asked Feb 24 '14 13:02

user1995781


1 Answers

here is the solution

rules: {
    shopname:
             {
    required: true,
    remote:"code.php",
          },
        }

Now in your code.php file-

If input is ok then display NOTHING.

if input incorrect then you have to display a QUOTED text like-

echo '"This Username is booked You Should Try VIVEK98779797 "';

so now by this code you can display custom error message by PHP using remote method

like image 79
vivex Avatar answered Oct 25 '22 23:10

vivex