iOS Development-uitextfield Mobile phone number and email verification

Source: Internet
Author: User

Whether the web is a mobile phone, the user registration when the time is large number of times need mobile phone number and e-mail address, and some apps can only use mobile phone number registration, iOS mailbox is relatively simple, but mobile phone number verification found a bit online, found that the three operators of the number segment changes, Through the latest number segment to determine the user's mobile phone verification error probability will be small, if there is missing number segment, welcome to Add.

/* Mobile authentication */+ (BOOL) Ismobilenumber: (NSString *) mobilenum {/** * mobile number * Mobile: 134/135/136/137/138/139/150/151/152/157    /158/159/182/183/184/187/188/147/178 * Unicom: 130/131/132/155/156/185/186/145/176 * Telecom: 133/153/180/181/189/177 * *    NSString *mobile = @ "^1 (3[0-9]|5[0-35-9]|8[025-9]) \\d{8}$";    /** * Mobile: China Mobile * 134[0-8]/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178 * * NSString *cm = @ "^1 (34[0-8]| (    3[5-9]|5[0127-9]|8[23478]|47|78) \\d) \\d{7}$ "; /** * Unicom: China Unicom * 130/131/132/152/155/156/185/186/145/176 * * NSString *CU = @ "^1 (3[0-2]|5[256]|8[56    ]|45|76) \\d{8}$ "; /** * China Telecom: Chinese Telecom * 133/153/180/181/189/177 * * NSString *ct = @ "^1 ((33|53|77|8[019)) [0-9]|349] \\d{7}        $";    Nspredicate *regextestmobile = [Nspredicate predicatewithformat:@ "Self MATCHES%@", MOBILE];    Nspredicate *REGEXTESTCM = [Nspredicate predicatewithformat:@ "Self MATCHES%@", CM]; Nspredicate *regextesTCU = [Nspredicate predicatewithformat:@ "Self MATCHES%@", CU];        Nspredicate *REGEXTESTCT = [Nspredicate predicatewithformat:@ "Self MATCHES%@", CT];        if ([regextestmobile evaluatewithobject:mobilenum] = = YES) | |        ([regextestcm evaluatewithobject:mobilenum] = = YES) | |        ([regextestct evaluatewithobject:mobilenum] = = YES) | | ([regextestcu evaluatewithobject:mobilenum] = = YES))    {return YES;    } else {return NO; }}/* Mailbox Verification */+ (BOOL) Isvalidateemail: (NSString *) Email {nsstring *emailregex = @ "[a-z0-9a-z._%+-][email protected] [A-za-z0-9.-]+\\. [A-za-z]    {2,4} ";    Nspredicate *emailtest = [Nspredicate predicatewithformat:@ "Self MATCHES%@", Emailregex]; return [Emailtest Evaluatewithobject:email];}

  

iOS Development-uitextfield Mobile phone number and email verification

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.