Using JQuery Validation plugin, I am trying to call the .valid() method without the side-effects of displaying error messages on screen. I have tried a number of scenarios w
You can do this without using CSS hacks by calling checkForm()
.
var isValid = $('#signup').validate().checkForm(); // true|false
checkForm()
does not trigger UI changes.
However, there is one side effect. Form fields will now be validated on change/focus/blur, which may be undesirable. You can disable this behavior by resetting the submitted
object:
$('#signup').validate().submitted = {};
Which results in:
var validate = $('#signup').validate(); // Get validate instance
var isValid = validate.checkForm(); // Valid?
validate.submitted = {}; // Reset immediate form field checking mode
Well instead of trying to disable any error placement made by the plugin you could use CSS to 'force' hiding the create error messages elements. Something like:
label.myvalidationclass { display: none !important; }
Where myvalidationclass
is either the default error class name or your own.
I'm aware it is not a very nice solution but in my opinion, displaying error messages is one of the core feature of the plugin.
d.