Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
69db1e3d
Commit
69db1e3d
authored
Apr 28, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
53e57198
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
bpo-web/app/base/utils/idcardClient.js
+23
-6
No files found.
bpo-web/app/base/utils/idcardClient.js
View file @
69db1e3d
...
...
@@ -158,7 +158,6 @@ class IdcardClient {
}
async
isHKCard
(
card
)
{
// 港澳居民来往内地通行证
// 规则: H/M + 10位或6位数字
...
...
@@ -197,13 +196,31 @@ class IdcardClient {
}
async
isAccountCard
(
card
)
{
// 户口本
// 规则: 15位数字, 18位数字, 17位数字 + X
// 样本: 441421999707223115
var
reg
=
/
(
^
\d{15}
$
)
|
(
^
\d{18}
$
)
|
(
^
\d{17}(\d
|X|x
)
$
)
/
;
if
(
reg
.
test
(
card
)
===
false
)
{
return
{
'status'
:
0
,
'msg'
:
'户口本号码不合规'
};
}
else
{
return
{
'status'
:
1
,
'msg'
:
'校验通过'
};
}
}
module
.
exports
=
IdcardClient
;
// 函数参数必须是字符串,因为二代身份证号码是十八位,而在javascript中,十八位的数值会超出计算范围,造成不精确的结果,导致最后两位和计算的值不一致,从而该函数出现错误。
// 详情查看javascript的数值范围
function
checkIDCard
(
idcode
)
{
async
isOfficerCard
(
card
)
{
// 军官证
// 规则: 军/兵/士/文/职/广/(其他中文) + "字第" + 4到8位字母或数字 + "号"
// 样本: 军字第2001988号, 士字第P011816X号
var
reg
=
/^
[\u
4E00-
\u
9FA5
](
字第
)([
0-9a-zA-Z
]{4,8})(
号
?)
$/
;
if
(
reg
.
test
(
card
)
===
false
)
{
return
{
'status'
:
0
,
'msg'
:
'军官证号不合规'
};
}
else
{
return
{
'status'
:
1
,
'msg'
:
'校验通过'
};
}
}
}
module
.
exports
=
IdcardClient
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment