title: angularjs form textbox validation: Enter nine digits or leave it empty
body: <p>I got a requirement to validate a textbox, when the user chooses to enter Tax Id Number, they have to enter 9 digit otherwise leave the textbox empty upon which the form is valid and a submit button is enabled. I am trying to do it this way. but this is not working. Please let me know better ways to do this.</p>
  
  <pre><code>   &lt;form name ="tinForm"&gt;
          &lt;div class="form-group"&gt;
                 &lt;input type="text"
                       ng-model="person.tin"
                       name="tin"
                       ng-minlength="9"
                       maxlength="9"/&gt;
                   &lt;span class="help-block" ng-show="tinForm.tin.$invalid"&gt; Please enter 9 digits &lt;/span&gt;
               &lt;/div&gt;
            &lt;/form&gt;
  
         &lt;div&gt;
             &lt;button ng-disabled="!tinForm.person.tin.$valid"&gt;Submit&lt;/button&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Thanks.</p>