使用javascript进行以下条件的电话号码验证 [英] for phone number validation of following conditions using javascript
问题描述
来电和来电是两个文本字段输入电话号码,他们有以下验证。
号码丢失
标签必须只包含数字和最大字段长度18
不能是1212121212或1234567890
不能拥有所有相同的数字
不能与调用相同的价值
如果Calling To:验证失败,当用户选择完成后,将显示以下错误消息:
无效拨打电话号码。
拨打号码:
- 长度必须为10到18个字符且仅限数字。
- 不能与呼叫来源相同。
- 不能包含所有相同的数字(例如7777777777)。
- 不能使用1212121212或1234567890这样的格式。
如果有人可以帮我解决这个问题,那将非常有帮助。
紧急情况被删除 - O. riginalGriff [/ edit]
calling to and calling from are two text fields to enter phone numbers and they have following validations.
Number is missing
tag must contain only numbers and a maximum field length of 18
cannot be 1212121212 or 1234567890
cannot have all the same digits
cannot be the same value as Calling From
"If the Calling To: validation fails the following error message will be shown when the user chooses done:
"Invalid Calling to phone number.
The Calling To Number:
- Must be 10 to 18 characters in length and numeric only.
- Cannot be the same value as the Calling From.
- Cannot consist of all the same numbers (for example 7777777777).
- Cannot have a format like 1212121212 or 1234567890."
It would be really helpful if someone could help me out on this code.
[edit]Urgency deleted - OriginalGriff[/edit]
推荐答案
您可以使用substr和indexOf将数字视为一个字符串,只需几个循环即可获得解决方案。另一种选择只是使用正则表达式。从网上获取一个并改变它。
我假设不允许JQuery。
在发布您的代码之前,您不会得到编码答案。
You could use substr and indexOf to treat the numbers as a string and with a few loops you''ll have your solution. The other option is simply to use a regular expression. Get one from the web and alter it.
I''m assuming JQuery is not allowed.
You won''t get a coded answer until you post the code you have.
使用SubString,Length函数。
Use SubString, Length functions.
这篇关于使用javascript进行以下条件的电话号码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!