简体   繁体   English

验证表格中的电话号码……真的卡住了

[英]validation for phone number in a form…Really Stuck

Before you start flaming or anything at all, READ THIS.在开始燃烧或任何事情之前,请阅读此内容。 I have a regular expression verifying the format of a phone number entered in a form is correct.我有一个正则表达式来验证表单中输入的电话号码的格式是否正确。 NOW what I am hoping to find is IF someone knows a way to verify if that number exists..,so if the number doesnt exist and the user enters it.现在我希望找到的是如果有人知道一种方法来验证该号码是否存在..,那么如果该号码不存在并且用户输入它。 user will get an error message phone number does not exist and they will be prompted to enter a WORKINg phone number....用户将收到错误消息电话号码不存在,并提示他们输入有效的电话号码....

I have looked ALL over the seas of google but could not find a phone number validator not a format checker like regex...我已经在谷歌的海洋中寻找过所有东西,但找不到电话号码验证器而不是像正则表达式这样的格式检查器......

This is my last hope..这是我最后的希望。。

In order to check if a phone number really exists (and belongs to the user who's filling your form) , I see only one solution: try to communicate with that phone.为了检查电话号码是否真的存在(并且属于填写表格的用户) ,我只看到一个解决方案:尝试与该电话进行通信。

What's generally done is sending an SMS with a validation code to the phone number -- and ask the user to type that code once he has received the SMS.通常所做的是将带有验证码的短信发送到电话号码 - 并要求用户在收到短信后输入该代码。

This way, you'll be sure that:这样,您将确定:

  • The phone number exists,电话号码存在,
  • And belongs to the current user.并且属于当前用户。


Of course, make sure you put some security measure in place, to prevent anyone from using your form to spam some number:当然,请确保您采取了一些安全措施,以防止任何人使用您的表单发送垃圾邮件:

  • Make sure one user cannot send more than X SMS per hour/day,确保一个用户每小时/每天发送的短信不能超过 X 条,
  • Make sure no more than 2 or 3 SMS can be sent to the same number per day/week确保每天/每周向同一个号码发送的短信不超过 2 或 3 条

The short answer is no.最简洁的答案是不。 You would need access to a database containing all the world's phone numbers - a sort of combined affair from the big providers.您将需要访问包含世界上所有电话号码的数据库 - 一种来自大型提供商的联合事务。 Having said that you could set up a system whereby you actually phone the number automatically and ask the user to enter a code.话虽如此,您可以设置一个系统,您实际上可以自动拨打该号码并要求用户输入代码。 This would require a lot of set-up and would cost a fair bit.这将需要大量的设置并且会花费相当多的费用。 That is the only way you could do such a thing.这是你能做这种事情的唯一方法。

For mobile numbers you could also use SMS and require a reply.对于手机号码,您也可以使用 SMS 并要求回复。

Maybe MaxMind can help you: http://www.maxmind.com/app/telephone_overview也许MaxMind可以帮助你: http://www.maxmind.com/app/telephone_overview

It provides a nice API, but its not free.它提供了一个不错的 API,但它不是免费的。

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

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