Last active
August 29, 2015 14:03
判断输入的参数是否是个合格的固定电话号码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @descrition:判断输入的参数是否是个合格的固定电话号码。 | |
* @param:str->待验证的固定电话号码。 | |
* @return : true表示验证合格。 | |
* | |
**/ | |
var isfixedphone = function(str) { | |
/** | |
* | |
* @desctition:规则->区号3-4位,号码7-8位,可以有分机号,分机号为3-4为,格式如下:"0775-85333333-123" | |
* | |
*/ | |
var pattern = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/; | |
return pattern.test(str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment