如何在目标c中检查用户输入的电话号码是否有效? [英] How to check user entered phone number is valid or not in Objective c?

查看:65
本文介绍了如何在目标c中检查用户输入的电话号码是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我已使用国家/地区代码验证电话号码,例如用户输入的号码是44557788991并选择国家/地区美国.与其他国家/地区一样,如何检查电话号码是否有效

In my project i have validate a phone number with country code like if user enter number is 44557788991 and select country US.same like for other country how can i check the phone number is valid or not.

在按钮上单击我必须检查号码是否有效.

on button click i have to check number is valid or not.

推荐答案

我认为您想检查国家/地区的数字.为此,您必须使用以下演示

I think you want to check the number country wise. for this you have to use following demo

https://github.com/rmaddy/RMPhoneFormat

英国

    RMPhoneFormat *fmt = [[RMPhoneFormat alloc] initWithDefaultCountry:@"uk"];
    NSString *numberString = // the phone number to format
    NSString *formattedNumber = [fmt format:numberString];

对于澳大利亚

RMPhoneFormat *fmt = [RMPhoneFormat instance];
NSString *callingCode = [fmt callingCodeForCountryCode:@"AU"]; // Australia - returns 61
NSString *defaultCallingCode = [fmt defaultCallingCode]; // based on current Region Format (locale)

以此类推...

这篇关于如何在目标c中检查用户输入的电话号码是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆