AngularJS Form Verification mobile phone number instance (not required), angularjs is required
The Code is as follows:
<Form ng-app = "myApp" ng-controller = "validateCtrl" name = "myForm" novalidate> <p> Tel: <br> <input type = "text" name = "phone" ng-model = "phone" ng-pattern = "/(^ $) | ^ (\ + 86) | (86 ))? 1 [34578] \ d {9}) $/"> <span style =" color: red "ng-show =" myForm. phone. $ dirty & myForm. phone. $ invalid "> incorrect contact number format! </Span> </p> <input type = "submit" ng-disabled = "myForm. $ invalid"> </p> </form>
Regular Expression:
1. null match: ^ $
2. Matching mobile phone number: ^ (\ + 86) | (86 ))? 1 [34578] \ d {9}) $
3. display the control prompt: ng-show = "myForm. phone. $ dirty & myForm. phone. $ invalid"
The example of the above AngularJS form to verify the mobile phone number (not required) is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the help house.