I\'m using the jQuery Validation plugin and want to disable the or element/container it creates to display the error \'message\'.
Basically, I want the input element wi
As I am using CSS to style the label.valid, label.error in jquery validate, this button cleared all the errors and left and data in the form fields in tact.
<button onclick="$('label.error').css('display', 'none');return false;">Clear Error </button>
You can add an onfocus and an onkeyup that would remove the error message.
$("selector").validate({
onkeyup: false,
onfocusout: false
});
I had a project that developed by another validation library, I wanted to add validate library to use its features for check the form is valid or not (used validation library doesn't have that feature)
My soloution was : I just added validate library by its CDN
and use validate feature on click :
$(document).on('click','#buttonID',function(){
var form = $( "#formID" );
form.validate();
console.log(form.valid());
});
and tried to hide error messages that raised by jquery validate by adding CSS code:
label.error{
display: none!important;
}
You could set the showErrors option to a function that only performs element highlighting:
$("selector").validate({
showErrors: function() {
if (this.settings.highlight) {
for (var i = 0; this.errorList[i]; ++i) {
this.settings.highlight.call(this, this.errorList[i].element,
this.settings.errorClass, this.settings.validClass);
}
}
if (this.settings.unhighlight) {
for (var i = 0, elements = this.validElements(); elements[i]; ++i) {
this.settings.unhighlight.call(this, elements[i],
this.settings.errorClass, this.settings.validClass);
}
}
}
});
That relies heavily on the validation plugin's internals, though, so it's probably not safe. The best would be for the plugin to expose a defaultHighlightElements()
method the same way it does for defaultShowErrors()
, but it's not the case (yet).