form.verify({
username: function(value, item) {
if (value == '') {
return '请输入用户名';
}
if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
return '用户名不能有特殊字符';
}
if (/(^\_)|(\__)|(\_+$)/.test(value)) {
return '用户名首尾不能出现下划线\'_\'';
}
if (/\p{Unified_Ideograph}/u.test(value)) {
return '用户名不能为汉字';
}
if (/^\d+\d+\d$/.test(value)) {
return '用户名不能全为数字';
}
if (value.length > 14) {
return '用户名超出长度';
}
},
nickname: function(value, item) {
if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
return '用户名不能有特殊字符';
}
if (/(^\_)|(\__)|(\_+$)/.test(value)) {
return '用户名首尾不能出现下划线\'_\'';
}
if (value.length > 6) {
return '昵称超出长度,最长6位';
}
},
pass: function(value, item) {
if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
return '用户名不能有特殊字符';
}
if (/^[\S]{6,15}$/.test(value)) {
return '密码必须6到15位,且不能出现空格';
}
}
});
最后一个 pass密码验证,怎么也通不过,超过6位,他认为是不合法的。这是咋回事?
/^[\S]{6,15}$/
这个正则的意思就是密码6到15位,且不含有空格。所以需要在前面加个非。