title: HTML 5 / Angular - Form validation for number field
body: <p>I am having a problem with form validation in HTML 5.</p>
  
  <p>In my HTML I have this.</p>
  
  <pre><code>&lt;input class="form-control" name="max_count" type="number" min="1" ng-model="vm.count" required&gt;
  </code></pre>
  
  <p>Its a <code>NUMBER</code> field and <code>MIN</code> is <code>1</code>.</p>
  
  <p>I have this in my angular controller,</p>
  
  <pre><code>if (vm.dataForm.$valid) {
      // do my logic
  } else {
      alert ("Errors in Form");
  }
  </code></pre>
  
  <h2>Now the Question</h2>
  
  <p>I type <code>0</code> in the text box. Since the <code>min</code> is <code>1</code> it automatically set the value to <code>1</code>. (which is OK). Now I click the <code>Submit</code> button.</p>
  
  <p>After that I get the <code>alert</code>. </p>
  
  <p>Basically even though it updates the value from <code>0</code> to <code>1</code>, the form validation happens for the value <code>0</code>.</p>
  
  <p>How can I validate form with the values currently in the text field?</p>