Hi guys, Is there any way to redefine validation rules for a form in runtime? I'm trying to redefine my validation based on a radio button using something like:
jQuery("#myRadioButton").change(function(){ var selectedOption = jQuery("#myRadioButton:checked").val(); switch(selectedOption){ case '1': var validator =jQuery("#myForm").validate({ rules: { 'fieldOne': {required: true, maxLength: 6} }, messages: { 'fieldOne': {required: 'fieldOne invalid'} } }) validator.resetForm(); break; case '2': var validator =jQuery("#myForm").validate({ rules: { 'fieldTwo': {required: true, maxLength: 6} }, messages: { 'fieldTwo': {required: 'fieldOne invalid'} } }) validator.resetForm(); break; } }); It doesn't work. Each time I select an option in my radio button I'd like to use only the rules defined for that specific option. What happens in fact is that after the first selection the rules aren't modified at all. Any ideas? Ivan