Help with validation attached to a button

NickMalloy used Ask the Experts™
I'm trying to use the Jquery validation, but I only want certain fields to be attached to certain buttons. What is the best way to do this? I tried a simple click command surrounding it, but it doesn't work. What can I do?

   $("ctl00$MainContent$btnAddItem").click(function () {

            invalidHandler: function (e, validator) {
                var errors = validator.numberOfInvalids();
                if (errors) {
                    var message = errors == 1
                              ? 'You missed 1 field. It has been highlighted below'
                              : 'You missed ' + errors + ' fields.  They have been highlighted below';
                    $("div.error span").html(message);
                } else {
            focusInvalid: false,
            rules: {

                ctl00$MainContent$txtNewManu: "required",
                ctl00$MainContent$txtNewProd: "required",
                ctl00$MainContent$rdbProdType: "required",
                ctl00$MainContent$txtProdDesc: "required",
                ctl00$MainContent$rdbProdItemsDRR: "required",
                ctl00$MainContent$txtProdLike: "required",

                ctl00$MainContent$txtOldManu: "required",
                ctl00$MainContent$txtOldProd: "required"
            messages: {
                ctl00$MainContent$txtName: "Please enter your Full Name"


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use validator's dependency required methods. This allow you to pass one condition to the validator.

Let me know if you need more details.
NickMalloySystems Lead


I could be completely off on my readings, but I tried this

  ctl00$MainContent$txtNewManu: {
                    required: function () {
                        $("#btnAddItem").attr('click') == "true"

but it still validates this field when the other button is clicked???
On click of btnAddItem set set Add Button clicked flag to true.


ctl00$MainContent$txtNewManu: {
                    required: function () {
                        $("#btnAddItemClicked"). == "true"

And on click on btnAddItem
execute below code

 $("#btnAddItemClicked") = "true";

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial