我有一个文件.jsp,并根据select的值显示/隐藏div。忽略隐藏在验证中的div
如果我选择的值是“no”隐藏DIV,如果是“是”,显示在div
我用NG-要求是否需要验证的参数。
但是,如果值为“否”并且我验证了我的表单,我无法验证它,因为div隐藏的字段为空。
我测试了一些东西,但没有结果。
CODE
<div class="row" id="yesAuth">
<div class="col-md-6" ng-class="{ 'has-error': invalid.basicAuthForBackendUsername, 'has-success': valid.basicAuthForBackendUsername}">
<div class="form-group" >
<label for="basicAuthForBackendUsername">basic auth username *</label>
<input type="text" name="basicAuthForBackendUsername" class="form-control" placeholder="basic auth username" ng-model="api.basicAuthForBackendUsername" ng-required="true">
<span id="helpBlock" class="help-block" ng-show="help.basicAuthForBackendUsername.required">basic auth username is required.</span>
</div>
</div>
</div>
JS
$(function() {
$("#basicAuth").change(function() {
if($("#basicAuth option:selected").val() == 'yes'){
$('#yesAuth').show();
}
else{
$('#yesAuth').hide();
}
});
});
$("#basicAuth").validate({
ignore: ".hidden"
});
<style media="screen" type ="text/css">
.hidden {
visibility: hidden;
}
</style>
CSS我怎样才能解决我的问题?
非常感谢。
不为我工作.. – JackR