How do I validate fields in a closed fieldset...

How do I validate fields in a closed fieldset...

I found below script, and its perfect to open/close fieldsets. Meanwhile the fields in a closed fieldset isnt validated when the form is submitted.

I think it would be good that a fieldset including a field not parsing validation is opened...

Can someone help me.to fix that?

My script is:

<script type="text/javascript">
$('#dashboard legend').each(function() {
var tis = $(this), state = false, answer = tis.next('div').hide().css('height','auto').slideUp();
tis.click(function() {
 state = !state;
 answer.slideToggle(state);
 tis.toggleClass('active1',state);
});
  });
</script>