0

I am writing one angular application where one of the text box accepts phone number. Where user can enter alphanumeric values as an example

  811-834-8888
  1-800-ABC-PLAN Ext- 101

I tried using ng-patern but seems not working exactly what i wanted

my Code-

    <input class="form-control"  ng-pattern = "/^\+?\d{1,3}[- ]?\d{3}[- ]?\d{5}$/" name="field_{{ listIndex }}"  placeholder="" type="text" ng-model="phoneData['phone3']"minlength ="12" maxlength="100"  name="field_{{ listIndex }}"   style="display:inline-block; width:230px" />

Can somebody help me to write proper regEx for the above phone number?

saurav
  • 219
  • 1
  • 13
  • 2
    "TL;DR don't use a regular expression to [validate complex real-world data like phone numbers](http://stackoverflow.com/questions/4338267/validate-phone-number-with-javascript/5059082#5059082) or URLs. Use a [specialized library.](https://github.com/googlei18n/libphonenumber)" – ʰᵈˑ Apr 11 '17 at 09:51
  • This will help you, http://embed.plnkr.co/I0J0Zi/preview – Prabu Apr 11 '17 at 09:54

0 Answers0