0

I am using jquery validation plugin(jqueryvalidation.org) for my input validations.

I have a text box say IP address . I have written IP address validation . This works fine . I have an "Update" button below this IP address text box. I have to compare this IP address(user input) with the database value. If both are different then allow the user to click "Update". If both are same then do not allow the user to "Update"

Is there any way to achieve this using jquery validation plugin?

Thanks.

JavaUser
  • 25,542
  • 46
  • 113
  • 139

1 Answers1

0

Yes you can just add a custom rule and return true or false based on your logic and validation will not allow a invalid form to be submitted. See below as example.

jQuery.validator.addMethod("Same IP", function(value, element) {
    //Your Validation Here
    return (value != your_db_IP); // return bool here if valid or not.
}, "IP should be different");

Please refer - https://jqueryvalidation.org/jQuery.validator.addMethod/

koolhuman
  • 1,581
  • 15
  • 25