1

I am trying to validate a single input to check numbers 1-99, I am wondering if I can do this in angular without having it wrapped in a form. Not a problem if it needs a form, just curious if it has to have it. Here's what I'm attempting -

<div class="errorMulti" ng-show="multiAdd.$error.maxlength">Error</div>
<input type='text' ng-model="multiAdd" placeholder='Number of levels to add 1-99' ng-maxlength="2"> 

Pretty straight forward, but doesn't seem to work. Any insight? thanks!

ajmajmajma
  • 13,712
  • 24
  • 79
  • 133

1 Answers1

-1
<div ng-app>
   <form name="myform">
    <div class="errorMulti" ng-show="myform.multiAdd.$error.maxlength">Error</div>
    <input type='text' name="multiAdd" ng-model="multiAdd" placeholder='Number of levels to add 1-99' ng-maxlength="2">
    </form>
 </div>

Check the JSfiddle: http://jsfiddle.net/15ugz6j3/

Md. Al-Amin
  • 1,423
  • 1
  • 13
  • 26
  • 6
    I don't understand how this can be the accepted answer. The question is "How do I validate *outside* forms" and your answer is "wrap it in a form"????? –  May 13 '18 at 12:13