Jquery Validation Required Multiple Condition

This is snippet for how to set rules if you have few condition for error message. Example when user select value1, required is true but when user select value2, required is false

 

Set condition

 phone: {
   required: function (element) {
     if($("selector").val() == 'value') {
     return true;
     }
     else {
     return false;
     }
 },
 minlength: 6
 },

 

Set error message

 phone: {
  required: "phone number is required",
  minlength: "please key in atleast 6 digit"
 }

Here also few related post that might interested you

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.