user1001421 user1001421 - 7 months ago 17
Javascript Question

jquery validation not working on an accordion

sorry for the slightly general question here, but is there any reason why the jquery validate plugin would stop working on a form split across an accordion?

Just to explain, and I'm sorry I can't give a URL to an example.
I've got an asp.net form which is split across an accordion. The mandatory fields are only on the first accordion panel. When this panel is open the validation works. If any of the other panels are open it won't validate.

For various strange reasons I'm calling the validation in an odd way. EG:

$('#submitBtn').click(function(){
$('#form1').valid();
if($('#form1').valid()){
alert('valid');
} else {
alert('invalid');
return false;
}
});


Am I missing something obvious?

Thanks.

Answer

By default, hidden input are ignored from validate plugin. Try this when initialising your jquery plugin which maybe could works for invisible input:

$("#form1").validate({
    ignore: "",
    ...
});