How Do I Keep A Validated Masked US Phone Number Validated With ng-pattern in AngularJS From Invalidating If Too Many Digits Are Entered
<p>I have trying to figure out a way to validate an input that is masked to display US based phone numbers as <code>(###) ###-####</code> I have tried a few things and the closest thing I have found is using </p>

<pre><code>&lt;form name="phone_form" novalidate&gt;
    &lt;input name="phone" class="phone_us" type="tel" ng-model="phone" placeholder="(555) 555-1212" ng-pattern="/^\(?(\d{3})\)?[ .-]?(\d{3})[ .-]?(\d{4})$/" /&gt;
    &lt;span style="color:red" ng-show="phone_form.phone.$error.pattern"&gt;Invalid Phone Number&lt;/span&gt;
&lt;/form&gt;
</code></pre>

<p>I pulled the regex from - <a href="https://stackoverflow.com/questions/18900308/angularjs-dynamic-ng-pattern-validation">Angularjs dynamic ng-pattern validation</a> - This successfully validates the input and matches the use case, it even throws the right error and displays the correct message. However as soon as you enter any digit beyond the 10 digits of the phone number the error is triggered and the input is invalid again. If I backspace one digit and add one digit again then the input validates once more as long as i dont add any more digits. The field is masked so you can not see any extra digits outside the displayed phone number and even if you try to enter 10 digits past the valid phone number all you have to do to re-validate the form successfully is backspace one digit and enter it again.</p>

<p>I've tried a few variations of max-length and min-length or max="#" etc. And I can't figure it out.</p>

<p>I am using Angular 1.5.7</p>

<p>A plunkr of where I am at can be found here:</p>

<p><a href="http://plnkr.co/edit/Ln7SciLSpnLJRZdA0P2N?p=preview" rel="nofollow noreferrer">http://plnkr.co/edit/Ln7SciLSpnLJRZdA0P2N?p=preview</a></p>