jQuery Validation plugin: disable validation for specified submit buttons when there is submitHandle
- by ccppjava
Ok, I am using umbraco forum module, and on the comment form it uses jquery validate plugin.
The problem is that I have added a search button on the same page using a UserControl, the search submit button triggers the comment form submission validation.
I have done some research, and added the 'cancel' css class to the button. This bypass the first validation issue, however, it still fall into the 'submitHandler'. Have read the source code and find a way to detect whether the search button triggers the submission. however, there is not a nice way to bypass the handler.
I am currently using a ugly way to do it: create javascript errors! I would like to know a nicer way to do the job. Many thanks!
Btw, I am currently using:
submitHandler: function (form) {
$(form).find(':hidden').each(function () {
var name = $(this).attr('name');
if (name && name.indexOf('btnSearch') === name.length - 'btnSearch'.length) {
// this is a dirty hack to avoid the validate plugin to work for the button
eval("var error = 1 2 ''");
}
});
// original code from umbraco ignored here....
}
...............