javascript - ngMessage validation on checkboxes undefined -
i have following code:
<label for="over_13"> <input type="checkbox" name="over_13" ng-model="user.over_13" ng-required="user.over_13==true"> <span>i'm on 13</span> </label> <ng-messages class="modal-error" for="registerform.over_13.$error" ng-show="registerform.$submitted" class="error-message"> <ng-message when="required">are on 13 years old?</ng-message> </ng-messages>
but when run follow in html of page via chrome inspect
<ng-messages class="modal-error ng-inactive" for="registerform.over_13.$error" ng-show="registerform.$submitted"> <!-- ngmessage: undefined --> </ng-messages>
am missing something?
also using required
instead of ng-required produced same error.
<label for="over_13"> <input type="checkbox" name="over_13" ng-model="user.over_13" required> <span>i'm on 13</span> </label>
you misusing for
, it'll need element same id
. won't work name
, not $error
.
why have ng-show
condition ng-message
ng-show="registerform.$submitted"
should not able submit form since checkbox required
. also, have declared class
attribute twice.
confusing should work.
<form name="registerform"> <label> <input type="checkbox" name="over_13" ng-model="user.over_13" required> <span>i'm on 13</span> </label> <ng-messages ng-show="registerform.over_13.$invalid"> <ng-message when="required">are on 13 years old?</ng-message> </ng-messages> </form>
Comments
Post a Comment