1
執行驗證我有一個表格如下圖所示:如何Angular.js
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="nomargin">Let us know your concern or question and we will try to respond within 24 hours.</h4>
</div>
<div class="modal-body paddingmodal2">
<form id="support-form" name="supportForm" class="nobottommargin" novalidate="">
<div class="col_full">
<label for="login-form-username">Description <small>*</small></label>
<textarea rows="4" cols="50" type="text" ng-class="{'error': submitted && supportForm.description.$error.required}" id="login-form-username" name="username" class="sm-form-control" ng-model = 'support.description' required/>
</div>
<div class="alert" role="alert" ng-class="{'alert-danger':!isLoginSuccess, 'alert-success':isLoginSuccess}" ng-show="isShowLoginAlert" ng-bind="loginSubmitStatusMsg"></div>
<div class="col_full nobottommargin no-margin-col-full">
<button type="submit" class="button button-3d button-black nomargin col_full" id="login-form-submit" name="submit-bt" ng-click="saveSupportData(supportForm,support)" ng-disabled="isDisableLoginBtn">Submit</button>
</div>
</form>
</div>
的JavaScript:
$scope.saveSupportData = function(supportForm,data){
if(supportForm.$invalid){
return;
}
}
當我點擊按鈕上的文本區域邊界應強調的,但它不是發生。
任何人都可以提供幫助。
喜Ghazanfar它不工作。 – MMR
您也可以使用$ invalid爲必填字段 ng-class =「{'error':submitted && supportForm.description。$ invalid}」 –
仍然沒有出現 – MMR