Can I dynamically set errorContainer in jQuery validation, which means showing different error container base on the button clicked.
This is what I am trying to do, but seems doesn't work:
$('#b1').click(function(evt) {
$('#form1').validate().resetForm();
validator.settings.errorContainer = $('#m1');
validator.settings.errorLabelContainer = $('ul', $('#m1'));
ValidateAndSubmit(evt)
if (evt.isDefaultPrevented())
return false;
alert("b1 clicked");
});
$('#b2').click(function(evt) {
$('#form1').validate().resetForm();
validator.settings.errorContainer = $('#m2');
validator.settings.errorLabelContainer = $('ul', $('#m2'));
ValidateAndSubmit(evt);
if (evt.isDefaultPrevented())
return false;
alert("b2 clicked");
});
the reason I'm doing this, because I'm using asp.net webform all my module inside one form tag, so I can't define another form inside existing form and set validation for each form, and I can only have one validation bind to the form.
I am using encosia's solution to simulate validation group using jQuery validation for sub-form under one form tag which is working perfectly, but in some case sub-forms under different tabs, so I want to showing the error container in each tab.
I have created a simple sample to explain what i'm trying to do sample here