-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
day13 #22
Comments
/*
账号:
* 不能为空,
* 不能使用特殊字符(数字、字母、下划线、-),
* 长度6-20
*/
var _username = username.value;
if(!/^[\w\-]{6,20}$/.test(_username)) {
alert('用户名不合法');
return false;
}
/*
昵称只能输入中文
*/
var _nickname = nickname.value;
if(!/^[\u2E80-\u9FFF]+$/.test(_nickname)) {
alert('昵称必须为中文');
return false;
}
/*
电子邮件
jinrong.xie@qq.com
x1@qq.com
x_2@163.com
x-x@a-r.com.cn
*/
var _email = email.value;
if(!/^[\w\-\.]+@[\da-z\-]+(\.[a-z]{2,3}){1,2}$/.test(_email)) {
alert('邮箱地址不合法');
return false;
}
/*
密码
* 长度小于20
* 不能包含空格
*/
var _psw = password.value;
if(!/^\S{1,19}$/.test(_psw)) {
alert('密码不合法');
return false;
}
/*
身份证
18/15位
445655 19900707 2165
445655 19900707 211x
*/
var _identity = identity.value;
if(!/^(\d{14}|\d{17})[\dx]$/.test(_identity)) {
alert('身份证不合法');
return false;
}
/*
手机号码
*/
var _phone = phone.value;
if(!/^1[34578]\d{9}$/.test(_phone)) {
alert('手机号不合法');
return false;
}
/*
生日
1999/05/08
1999-5-8
19990508
1988/05/01
*/
var _birthday = birthday.value;
if(!/^\d{4}([\/\-\.]?)\d{1,2}\1\d{1,2}$/.test(_birthday)) {
alert('生日格式不合法');
return false;
} |
整数或者小数:^[0-9]+.{0,1}[0-9]{0,2}$ |
The text was updated successfully, but these errors were encountered: