我在JavaScript中工作,我目前正在使用一个应用程序进行日期和时间验证。 我有一个单选按钮,可以从下拉列表中控制内容,是否显示取决于单选按钮被选为是或否。 一个愚蠢的想法,我无法理解,当我选择单选按钮为否,并在刷新页面后,甚至当日期和时间验证出现时,下拉含义的内容再次显示。 因此,图片将更好地展现情况
还有我的代码
$(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函数工作正常,但只有在我提交表单后我在表单中得到一些需要的消息,我才会得到这个愚蠢的错误。 任何评论或建议如何避免这种情况甚至解决它。 谢谢:)