AngularJS Form Verification mobile phone number instance (not required), angularjs is required

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.