Validate phone number using angular js

前端 未结 9 542
情歌与酒
情歌与酒 2020-12-03 00:13

Want to set phone-number to 10 digits, How can I do this using Angular js.

This is what I have tried:



        
9条回答
  •  旧时难觅i
    2020-12-03 00:44

    Use ng-pattern, in this example you can validate a simple patern with 10 numbers, when the patern is not matched ,the message is show and the button is disabled.

     

    write a phone number

    Also you can use another complex patern like

    ^+?\d{1,3}?[- .]?(?(?:\d{2,3}))?[- .]?\d\d\d[- .]?\d\d\d\d$

    , for more complex phone numbers

提交回复
热议问题