I am begginer in JavaScript, and I am currently working one application for date and time validation. I have one radio button which control content from dropdown, will show or not depending is radio button selected to Yes or No. One stupid think which I can not understand, when I select radio button to No, and after refreshing page, or even when date and time validation appear, the content of dropdown meanu is again display. So picture will demostrante situation better
And also my code
$(document).ready(function () {
$("input[name$='Chapel']").click(function () {
var test = $(this).val();
if (test == 'No') {
$("div#hideChapel").hide();
}
else {
$("div#hideChapel").show();
}
});
});
HTML
<div class="form-group">
<label class="control-label col-md-3" for="Chapel">Chapel</label>
<div class="col-md-9">
<label class="radio-inline">
<div class="choice" id="uniform-Chapel"><span class=""><input class="styled" htmlattributes="{ checked = true }" id="Chapel" name="Chapel" type="radio" value="Yes" autocomplete="off"></span></div>
Yes
</label>
<label class="radio-inline">
<div class="choice" id="uniform-Chapel"><span class="checked"><input checked="checked" class="styled" htmlattributes="{ checked = true }" id="Chapel" name="Chapel" type="radio" value="No" autocomplete="off"></span></div>
No
</label>
<span class="field-validation-valid text-danger" data-valmsg-for="Chapel" data-valmsg-replace="true"></span>
</div>
</div>
P.S Function work fine, but only if I get some require message in form after I submit form, I get this stupid bug. Any comment or suggestion how to avoid this or even solve it. Thank you :)