I am styling a zend powered form so have don’t want to change markup.
I am trying to hide the textarea and it’s label when the radio button value is no but when it is yes the textarea and label should appear.
Problem I have is if the textarea is not filled out once yes is selected, and the submit button is pressed, zend shows it’s own error message which is good, but because the page is reloaded due to the submit action it keeps the value of yes on the form but hides the textarea and label, so you have to re-click the yes value to get them to appear again.
Goal – if the yes button is selected, the textarea and label appears, but if the textarea is not filled out and the submit button is hit, the error appears but also the yes value is still selected AND the textarea and label are still visible until no is hit!
My code so far –
$(function(){
if ($('#declarations-refused-y').is(':selected')) {
$('#declarations-refusedText-label, #declarations-refusedText-element').show();
}
else {
$('#declarations-refusedText-label, #declarations-refusedText-element').hide();
}
});
Use
:checkedinstead of:selected.