JQuery Acknowledge Remote Error Message

I am using the jquery validation plugin ( http://jqueryvalidation.org/ ) to validate the form. There is a field in which I want to perform remote confirmation.

Code example:

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

When it is invalid, it displays "Please correct this field." How can I create a custom error message for remote verification, for example, "An email address that is already in use. Use a different email."

Thanks.

+7
jquery validation
source share
5 answers

their documentation seems to show the message parameter. might be useful?

http://jqueryvalidation.org/validate

example on your 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 " } } }); 
+4
source share

here is the solution

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

Now in the code.php file -

If the input is OK, display ANYTHING .

if the input is incorrect, you need to display the text QUOTED , for example -

echo '"This username is reserved, you must try VIVEK98779797"';

So now with this code you can display your own error message using the remote method

+4
source share

Just pass an array of messages as the second argument to the validate () function. Specify a custom error message for remote verification using the remote control as shown below.

 $("#myform").validate({ rules: { email: { required: true, email: true, remote: "check-email.php" } }, messages: { email: { required: "This field is required", email: "Invalid Email Address", remote: "Email address already in use. Please use other email." } } }); 
+2
source share

I ran into the same problem, I found a solution similar to this.

 $(document).ready(function () { $( "#myform" ).validate({ rules: { email: { required: true, email: true, remote:"check-email.php" } }, messages: { email:"please fix this field" } }); }); 

try it

0
source share

Message: {remote: "something is wrong"}

/ * ** the server side should return "false" or "true", the type of the string, not logical. * /

0
source share

All Articles