Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
852409e5867bec325e9b1ed249008593b34d384c
1 parent
03e5d078
address detail err tip
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
public/js/common/index.js
public/js/shopping/order/address.js
public/js/common/index.js
View file @
852409e
...
...
@@ -56,8 +56,15 @@ function queryString() {
return
vars
;
}
function
getStrLength
(
str
)
{
var
cArr
=
str
.
match
(
/
[\u
4e00-
\u
9fa5a
]
/ig
);
return
str
.
length
+
(
cArr
===
null
?
0
:
cArr
.
length
);
}
module
.
exports
=
{
cookie
:
cookie
,
// 获取cookie
setCookie
:
setCookie
,
// 设置cookie
queryString
:
queryString
// query参数解析
queryString
:
queryString
,
// query参数解析
getStrLength
:
getStrLength
// 获取字符串长度(一个中文=2个字符)
};
...
...
public/js/shopping/order/address.js
View file @
852409e
...
...
@@ -7,6 +7,7 @@
var
$
=
require
(
'yoho-jquery'
),
Hbs
=
require
(
'yoho-handlebars'
),
cascadingAddress
=
require
(
'../../plugins/cascading-address'
),
common
=
require
(
'../common'
),
popup
=
require
(
'../../plugins/dialog'
);
var
$receiver
=
$
(
'#receiver'
);
...
...
@@ -15,6 +16,8 @@ var Dialog = popup.Dialog,
Confirm
=
popup
.
Confirm
,
Alert
=
popup
.
Alert
;
var
detailErr
=
'2-100字符。1个中文为2个字符'
;
var
addressDialogTpl
;
var
addressTpl
;
...
...
@@ -67,10 +70,6 @@ function validateAddress($el) {
{
noEmpty
:
true
,
err
:
'详细地址不能为空'
},
{
regx
:
/^
[\u
4e00-
\u
9fa5a-zA-Z
\d
#-()
]
+$/
,
err
:
'只能包含数字、字母、汉字、#、-、()及其组合'
}
],
mobile
:
[
...
...
@@ -121,6 +120,11 @@ function validateAddress($el) {
// 否则隐藏提示
$cur
.
siblings
(
'.error-tips'
).
hide
();
}
if
(
key
===
'detail'
&&
common
.
getStrLength
(
$cur
.
val
())
>
100
)
{
pass
=
false
;
$cur
.
siblings
(
'.error-tips'
).
find
(
'em'
).
text
(
detailErr
).
end
().
show
();
}
}
}
...
...
@@ -285,6 +289,17 @@ function initAddressContent($el, areaCode) {
if
(
areaCode
)
{
$el
.
address
.
setAddress
(
areaCode
+
''
);
// need convert to string
}
// blur验证
$
(
'.address-detail'
).
on
(
'blur'
,
function
()
{
var
$cur
=
$
(
this
);
if
(
common
.
getStrLength
(
$cur
.
val
())
>
100
)
{
$cur
.
siblings
(
'.error-tips'
).
find
(
'em'
).
text
(
detailErr
).
end
().
show
();
}
else
{
$cur
.
siblings
(
'.error-tips'
).
hide
();
}
});
}
/**
...
...
Please
register
or
login
to post a comment