jQuery Validation plugin: disable validation for specified submit buttons when there is submitHandle

Posted by ccppjava on Stack Overflow See other posts from Stack Overflow or by ccppjava
Published on 2010-05-12T16:10:47Z Indexed on 2010/05/12 16:14 UTC
Read the original article Hit count: 228

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....
        }

...............

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about validation