I managed to solve the problem in a different way...
Instead of validating the entire form with hundreds of input fields (a time consuming process), I validate only the modified fields, that is, I call $("form").validate().element(this)
, where this
is the input element that had its valued modified by the user.
Using jQuery
we can have something like this:
// Save button click
$("#save").click(function ()
{
var button = $(this);
button.button('loading');
// Selecting only Questions that had their answers modified...
var answers = // Your logic here to select the modified input fields
var valid = true;
answers.each(function ()
{
$(this).find("textarea:not(:disabled)").each(function ()
{
if (!$("form").validate().element(this))
{
$(this).focus();
valid = false;
return;
}
});
});
// If any of the answers is invalid return with validation messages...
if (!valid)
{
// Resetting Bootstrap's button back to it's original state
button.button('reset');
return;
}
... // Do the AJAX POST here
}