我有一個文件.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