Jquery Validation - Hide Error Message And Don't Submit The Form
I am using jQuery Validate for a form. I have a field that is required, but I don't want to display any error message for the field. I just want the form submission to be blocked.
Solution 1:
Quote OP:
"Is there a way to hide the rendering of the error message for a specific element, while still preventing the form submission?"
See the errorPlacement
callback function, which controls where messages are placed.
Use a conditional so that you return false
on the specific element, which effectively prevents a message from being placed, while allowing the default message placement on the rest.
$('#myform').validate({
rules: {
....
},
errorPlacement: function(error, element) {
if (element.attr('name') == 'myName') {
returnfalse; // no message placement
} else {
error.insertAfter(element); // default message placement
}
}
});
Post a Comment for "Jquery Validation - Hide Error Message And Don't Submit The Form"