I am using a very long expandable form. For example if question 1 is answered with “Yes”, question 1.1 will show and so on.
This works well with the following (simple) jquery script:
Selectmenu
<script type="text/javascript">
$(document).ready(function() {
$(".question").change(function() {
var itemValue = $(this).children(':selected').val();
if(itemValue != "" && itemValue != "N")
{
$(".questiont").show();
}
else
{
$(".questiont").hide();
}
});
});
</script>
HTML
<select name="question1[]" class='required txtBox'>
<option selected="selected"></option>
<option value="J">Yes</option>
<option value="N">No</option>
</select>
<table>
<tr class="questiont" style="display:none; border-collapse:collapse;">
<td>4.2</td>
<td>Textarea</td>
<td><textarea name="questiont[]" class="txtBox"></textarea></td>
</tr>
</table>
The problem is, that if 1 is “Yes” and thus 1.1 is shown, 1.1 should be filled. I am using jQuery validate for that.
The problem is that i don’t know how to combine the validation with a hidden or shown status.
Try this code: