Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
h5_activity
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谭新宇
h5_activity
Commits
949cd1dc
Commit
949cd1dc
authored
Jul 16, 2019
by
txy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'提取校验逻辑'
parent
7d321a71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
96 deletions
+105
-96
signup.js
showPhotos/js/page/signup.js
+105
-96
No files found.
showPhotos/js/page/signup.js
View file @
949cd1dc
...
...
@@ -100,103 +100,11 @@ function btnBindClick() {
var
addInput
=
JSON
.
parse
(
data
.
dataJson
).
addGroup
var
uploadImg
=
$
(
'#act31419345204861 img'
)
// 验证用户名
if
(
userName
.
attr
(
'c_validateempty'
)
==
'yes'
)
{
var
userNameVal
=
userName
.
val
()
var
userNameLen
=
userName
.
attr
(
'c_len'
)
if
(
userNameVal
==
''
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入参与者姓名'
});
return
false
}
else
if
(
userNameVal
.
length
>
userNameLen
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'参与者姓名不能超过'
+
userNameLen
+
'个字'
});
return
false
}
}
// 验证手机号
if
(
phonenum
.
attr
(
'c_validateempty'
)
==
'yes'
)
{
var
reg
=
/^1
[
3456789
]\d{9}
$/
var
phonenumVal
=
phonenum
.
val
()
var
phonenumLen
=
phonenum
.
attr
(
'c_len'
)
if
(
phonenumVal
==
''
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入参与者手机号码'
});
return
false
}
else
if
(
phonenumVal
.
length
>
phonenumLen
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'参与者手机号码不能超过'
+
phonenumLen
+
'个字'
});
return
false
}
else
if
(
!
reg
.
test
(
phonenumVal
))
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入正确的参与者手机号码'
});
return
false
}
}
// 验证活动宣言
if
(
introDuce
.
attr
(
'c_validateempty'
)
==
'yes'
)
{
var
introDuceVal
=
introDuce
.
val
()
var
introDuceLen
=
introDuce
.
attr
(
'c_len'
)
var
introDuceName
=
introDuce
.
attr
(
'c_name'
)
if
(
introDuceVal
==
''
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入'
+
introDuceName
});
return
false
}
else
if
(
introDuceVal
.
length
>
introDuceLen
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
introDuceName
+
'不能超过'
+
introDuceLen
+
'个字'
});
return
false
}
}
// 验证身份证
if
(
signInput
.
attr
(
'c_validateempty'
)
==
'yes'
)
{
var
signInputVal
=
signInput
.
val
()
var
signInputName
=
signInput
.
attr
(
'c_name'
)
var
signInputLen
=
signInput
.
attr
(
'c_len'
)
if
(
signInputVal
==
''
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入'
+
signInputName
});
return
false
}
else
if
(
signInputVal
.
length
>
signInputLen
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
signInputName
+
'不能超过'
+
signInputLen
+
'个字'
});
return
false
}
else
if
(
!
validateIDNumber
(
signInputVal
))
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'请输入正确的'
+
signInputName
});
return
false
}
var
flag
=
validateForm
();
if
(
!
flag
)
{
return
false
;
}
// 验证上传图片
if
(
uploadImg
.
attr
(
'src'
)
==
''
)
{
$
.
dialog
({
...
...
@@ -553,3 +461,103 @@ function validateIDNumber(card) {
}
return
true
}
// 验证用户姓名
function
validateUserName
(
userName
)
{
let
state
=
false
if
(
userName
!==
''
)
{
let
uName
=
userName
.
replace
(
/
\s
*/g
,
''
)
var
reg
=
/^
(([
a-zA-Z+
\.
?
\·
?a-zA-Z+
]{1,15}
$
)
|
([\u
4e00-
\u
9fa5+
\·
?
\u
4e00-
\u
9fa5+
]{1,15}
$
))
/
if
(
!
reg
.
test
(
uName
))
{
state
=
false
}
else
{
state
=
true
}
}
return
state
}
// 验证手机号
function
validatePhone
(
phonenum
)
{
let
state
=
false
if
(
phonenum
!==
''
)
{
var
reg
=
/^1
[
3456789
]\d{9}
$/
if
(
!
reg
.
test
(
phonenum
))
{
state
=
false
}
else
{
state
=
true
}
}
return
state
}
// 验证输入框
function
validateInput
(
$input
)
{
var
c_len
=
$input
.
attr
(
"c_len"
);
var
c_validateempty
=
$input
.
attr
(
"c_validateempty"
);
var
c_validate
=
$input
.
attr
(
"c_validate"
);
var
c_name
=
$input
.
attr
(
'c_name'
);
var
_value
=
$input
.
val
();
// 为空校验
if
(
c_validateempty
==
'yes'
&&
_value
==
''
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
c_name
+
'不能为空'
});
return
false
;
}
// 长度校验
if
(
_value
.
length
>
c_len
)
{
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
c_name
+
'不能超过'
+
c_len
+
'个字'
});
return
false
;
}
// 规则校验 c_validate = phone,idcard,username三种类型
if
(
c_validate
!==
''
){
if
(
c_validate
===
'phone'
&&
!
validatePhone
(
_value
))
{
// 手机校验
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'手机号格式错误'
});
return
false
;
}
else
if
(
c_validate
===
'idcard'
&&
!
validateIDNumber
(
_value
)){
// 身份证校验
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'身份证格式错误'
});
return
false
;
}
else
if
(
c_validate
===
'username'
&&
!
validateUserName
(
_value
)){
// 用户名称校验
$
.
dialog
({
type
:
'tips'
,
autoClose
:
3000
,
infoText
:
'用户名格式错误,请输入中文或者英文'
});
return
false
;
}
}
return
true
;
}
// 验证表单输入框
function
validateForm
()
{
var
inputs
=
$
(
'.sign-form .form-input-group-inner input'
);
var
flag
=
true
;
for
(
var
k
=
0
;
k
<
inputs
.
length
;
k
++
){
flag
=
validateInput
(
inputs
.
eq
(
k
));
if
(
!
flag
){
break
;
}
}
return
flag
}
\ No newline at end of file
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