jQuery validation depends

2019-06-03 21:51发布

问题:

Is it possible to add a depends onto an equalTo rule?

i.e.,

rule {   
    myFormFierld: if textbox name has been filled out add this equalTo rule..
}

回答1:

The answer is yes. You just need to declare it that way

billingAddress: {
  required:true,
  minlength:5
  equalTo: {
    param: "#shippingaddress",
    depends: "#compare:checked"
  }
}

Simple and beautiful. Via this ticket.