jQuery Validation plugin with two submit buttons?

前端 未结 3 1007
天命终不由人
天命终不由人 2020-12-04 22:51

I have one form with around 50 fields and two submit buttons, \"SAVE\" and \"SAVE & SUBMIT\". If the user clicks \"SAVE\", then validate only some values, eg. field1, fi

3条回答
  •  悲&欢浪女
    2020-12-04 23:25

    If you will use the same validation, maybe you should this code:

    Insert an hidden action, to say the validation the method to use after we click the button

    
    

    Then in your submit Handler:

    submitHandler: function (form, event) {
        var action = $("#formPagoContratista #action").val();
        if (action === "action_1") {
            firstFunction();
        }else if (action === "action_2") {
            secondFunction();
        }
    }
    

提交回复
热议问题