我想切換輸入css類如果驗證有效,我可以做如果無效,但我需要兩個類如果是有效的,如果不是。它是容易使,如果是無效的,但如何添加,如果是有效的,這裏是我的代碼,我現在:如果驗證是有效的輸入角度切換類
<form name="userForm" ng-submit="submitForm()" novalidate>
<input type="email" name="email" placeholder="E-mailadres" class="input-field" ng-model="user.email" required ng-class="{ 'has-error' : userForm.email.$invalid && !userForm.email.$pristine }" />
<p ng-show="userForm.email.$invalid && !userForm.email.$pristine" class="help-block">Enter a valid email.</p>
<input type="password" name="password" ng-model="user.password" placeholder="Wachtwoord" class="input-field" required />
<p ng-show="userForm.password.$invalid && !userForm.password.$pristine" class="help-block">You name is required.</p>
<button type="submit" class="btn hit-btn" ng-disabled="userForm.$invalid">Log in</button>
</form>
你會發現,我有類有錯誤,但我需要也類沒有錯誤
這工作正常,txanks –
永遠歡迎:) – Sankar