I have an asp.net form with a login section and a register section. There are two submit buttons that correspond to the appropriate section, login or register. I am using
I'm guessing you are using this validation plugin: JQuery Validation . The plugin uses the form tag as a validation group so to accomplish what you want you will need to remove rules depending on which button the user pushes. Also, you will need to add the rules back for the case where the validation fails then the user decides to click the other button.
Here's an example:
$(document).ready(function()
{
$("#form").validate({
invalidHandler: addRules
});
addRules();
$("#submit1").click(function(){
$(".group2").each(function(){
$(this).rules("remove");
});
});
$("#submit2").click(function(){
$(".group1").each(function(){
$(this).rules("remove");
});
});
});
var addRules = function(){
$("#input1").rules("add", {required:true});
$("#input2").rules("add", {required:true});
}
This approach allows you to add a class attribute (group1 or group2) to each of your inputs which acts as a validation group.