You cannot dynamically turn validation on/off for any/all parts of a form with this plugin.
However, you can use the .rules() method to dynamically add, remove, or over-ride your rules at any time, giving you a similar behavior.
Then you can use the .valid() method to test the form.
Put them each inside dedicated click event handlers.
$(document).ready(function() {
// initialize the plugin
$("#form1").validate({
ignore : '*:not([name]),:hidden'
// no rules; rules are set dynamically below
});
// Save Button
$('#save_button').on('click', function() {
// dynamically set the rules
$('input[name="email"]').rules('add', {
required: true,
....
});
// remove all rules from the other fields
$('input[name="city"]').rules('remove');
// force a test of the form
$("#form1").valid();
});
// Submit Button
$('#submit_button').on('click', function() {
// dynamically set the rules
$('input[name="city"]').rules('add', {
required: true,
....
});
// remove all rules from the other fields
$('input[name="email"]').rules('remove');
// force a test of the form
$("#form1").valid();
});
});
Proof-of-concept DEMO: http://jsfiddle.net/x6YWM/
If you have many fields, you can make this easier by setting appropriate classes on them like .ruleset1 and .ruleset2. Then you can target them as a group with the .rules() method. Just remember that you'll need to enclose them inside a jQuery .each() if the selector targets more than one element...
$('.ruleset1').each(function() { // target multiple elements
$(this).rules('add', { // apply the rules to each
required: true,
....
});
});