e.g. Say I have two textboxes A,B and two buttons C,D in a form. Then I want that on click of button C, if only textbox A is valid then form is valid, and on click of button D, if only textbox B is valid then form is valid.
Does anyone know how to do this?
Use ignore option.
$("form").validate({ignore: ".ignore"});
$("#c").click(function(){
//$("#a").removeClass("ignore");
//$("#b").addClass("ignore");
$(".step1").removeClass("ignore");
$(".step2").addClass("ignore");
$("form").valid();
});
$("#d").click(function(){
//$("#a").addClass("ignore");
//$("#b").removeClass("ignore");
$(".step1").addClass("ignore");
$(".step2").removeClass("ignore");
$("form").valid();
});
EDIT: as outlined in my comment @dannie.f post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With