4
I have a input
which I wish to validate via Angularjs. However, this input is not within a form. So, when trying to access the form validation information, I was unsuccessful:
<div class="form-group">
<input name="nick" type="text" class="form-control" ng-model="username.nick" ng-maxlength="10">
<span class="help-block" ng-show="nick.$error.maxlength">Máximo permitido é 10</span>
</div>
But if I do it that way, it works:
<form name="formUser">
<div class="form-group">
<input name="nick" type="text" class="form-control" ng-model="username.nick" ng-maxlength="10">
<span class="help-block" ng-show="formUser.nick.$error.maxlength">Máximo permitido é 10</span>
</div>
</form>
In this specific case, I would like to use the validation similar to the second example, but without form.
Is there any way to validate the angular, without using the form?
Tried to use the directive
ng-form
? See more here http://stackoverflow.com/questions/22098584/angularjs-input-validation-with-no-enclosing-form– abfurlan
@abfurlan seems to have just answered this. I have known about this directive for a short time.
– Wallace Maxters
Truth I just saw.
– abfurlan