angularjs - Validation message displayed by default -
i enter page , can see validation message immediately.
<div ng-class="{'has-error': test.$invalid}" class="form-group" > <input id="field" name="field" required class="form-control" ng-model="field" type="text"/> <div class="help-block error" ng-show="test.field.$error.required">required</div> </div>
how can avoid ?
your issue respect fact condition ng-show
test.field.$error.required
.
what's problem this?
even when page loads, field still not valid email id.
so, what's fix?
you need check user has clicked on field , field no longer pristine
.
how that?
in ng-show
, add following condition.
test.field.$error.required && test.field.$dirty
here working demo
Comments
Post a Comment