diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 1516131e85..e0d567b79f 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -338,18 +338,18 @@ $.fn.form = function(parameters) { blank: function($field) { return String($field.val()).trim() === ''; }, - valid: function(field) { + valid: function(field, showErrors) { var allValid = true ; if(field) { module.verbose('Checking if field is valid', field); - return module.validate.field(validation[field], field, false); + return module.validate.field(validation[field], field, !!showErrors); } else { module.verbose('Checking if form is valid'); $.each(validation, function(fieldName, field) { - if( !module.is.valid(fieldName) ) { + if( !module.is.valid(fieldName, showErrors) ) { allValid = false; } }); @@ -1235,7 +1235,9 @@ $.fn.form = function(parameters) { module.debug('Field depends on another value that is not present or empty. Skipping', $dependsField); } else if(field.rules !== undefined) { - $field.closest($group).removeClass(className.error); + if(showErrors) { + $field.closest($group).removeClass(className.error); + } $.each(field.rules, function(index, rule) { if( module.has.field(identifier)) { var invalidFields = module.validate.rule(field, rule,true) || [];