ansman/validate.js

Don't validate inputs inside hidden divs

Closed this issue · 1 comments

I have some inputs inside hidden divs, that show only under certain conditions. How can I skip the validation on those, so they do not validate if hidden, but validate if shown? For example I've been trying this, but it's not working properly (it's not toggling validation when the field is shown):

    Spouse_First_Name__c: function(value, attributes, attributeName, options, constraints) {
      if (attributes.Marital_Status__c){
        return null;
      } else {
        return {presence: true};
      }
    }

Fixed it like this:

    Spouse_First_Name__c: function(value, attributes, attributeName, options, constraints) {
      if ($('#Marital_Status__c').is(":visible")){
        return {presence: true};
      } else {
        return null;
      }
    },