Closed philipkueng closed 9 years ago
You can edit the validations template to do so:
<div ng-messages="field.$error"
class="validation"
ng-show="attrs.required==''|| attrs.required">
Just remove the ng-show condition here.
Thanks alot!
Edit: I've created my own template and implemented it succesfully. After that I created a new div, like you posted above, and added the ng-maxlength list-item like this:
<div ng-messages="field.$error"
class="validation">
<ul class="list-unstyled validation-errors"
ng-show="field.$invalid && (field.$touched || field.$dirty || form.$triedSubmit)">
<li ng-message="maxlength">Please do not exceed {{ attrs.maxlength }} characters</li>
</ul>
</div>
After that I implemented the form like this:
<div class="form-group">
<label class="control-label">
xyz
</label>
<input type="text"
class="form-control text-right"
placeholder="xyz"
ng-model="xyz"
input-decimal
ng-maxlength="50"/>
</div>
Seems not to work. What am I doing wrong?
Hm weird. That should work. I assume your input is wrapped into a form? I also wonder what input-decimal does. Does it work without. And if so, what happens if you use maxlength instead of ng-maxlength?
ping @devphil0 .
As you're assuming, I wrapped the input into a form. The directive input-decimal allows decimal numbers only.
I'm using the html-attribute maxlength as solution - you can close this issue. Thanks for your deployment.
Is there a way I can check the maxlength of a string without attaching the required tag?