简体   繁体   English

我如何验证该号码是否为有效的电话号码?

[英]how do i validate if the number is a valid phone number?

i have a phone number inputs like: 我有一个电话号码输入,例如:

Belgium: 0471712211 or 471712211 or 32471712211 or 0032471712211
UK: 0123456 or 123456 or 440123456 or 44123456 or 0044123456

Now i need to accept above inputs, but need to send always the number format only into this format +32471712211 or +44123456 but user can insert random formats, which is the problem. 现在,我需要接受上述输入,但是需要始终仅将数字格式发送为+32471712211或+44123456这种格式,但是用户可以插入随机格式,这就是问题所在。

Is there any PHP class out there for handling dialing numbers? 是否有任何用于处理拨号号码的PHP类? or any other php libraries for dealing the dialing numbers? 或任何其他处理拨号号码的PHP库?

You should use regex patterns . 您应该使用正则表达式模式 Add validator in application/forms/YourForm.php for field with phone number. 在包含电话号码的字段的application / forms / YourForm.php中添加验证器。

根据国家列表,您可以预先为禁用的文本框提供国家代码,而在电话号码文本框上可以绑定一个功能,该功能可以验证天气限制数是否与该国家代码匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM