i use the validate plugin a lot – its great.
my current setup, is a fix “closed” boxes, which contain fields.
what i want to do, is if the box contains mandatory fields which were not filled, the boxes should open trying to submit.
this is my code:
$("#ftblSubGroupsadd").validate({
invalidHandler: function(form, validator) {
alert('Note, a few mandatory fields remain un-answered. You may have to open some closed boxes');
$("label.error").closest("div[class=inside]").css("display","block");
$("label.error").closest("div.boxed").removeClass().addClass('box');
}
});
and here is an online demo.
the weird thing is that when you try submkit the first time, all you get is the alert().
but is you straight away click submit again, you get the alert() and only then, does the open/show code function, and the boxes open.
can someone give me a hand with why this is the case?
thanks!
ok, someone helped me on another list, and this code seems to work: