<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>注册</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" href="css/register.css">
<!--导入jquery-->
<script src="js/jquery-3.3.1.js"></script>
<script>
//校验用户名
function checkUserName() {
//1、获取控件username的值
var username = $("#username").val();
//2、定义正则表达式
var reg_username=/^w{8,20}$/;
//3、判断
var flag = reg_username.test(username);
if(flag){
$("#username").css("border","");
}else{
$("#username").css("border","solid 1px red");
}
return flag;
}
//校验密码
function checkPassword() {
//1、获取password控件的输入值
var password = $("#password").val();
//2、定义正则表达式
var reg_password = /^w{8,20}$/;
//3、判断
var flag = reg_password.test(password);
if(flag){
$("#password").css("border","solid 1px green");
}else{
$("#password").css("border","solid 2px red");
}
return flag;
}
//校验邮箱
function checkEmail() {
//1、获取email中的值
var email = $("#email").val();
//2、定义正则表达式
var reg_email = /^w+@w+.w+$/;
//3、判断
var flag = reg_email.test(email);
if(flag){
$("#email").css("border","solid 1px green");
}else{
$("#email").css("border","solid 2px red");
}
return flag;
}
//校验姓名
function checkname() {
//1、获取name的值
var name = $("#name").val();
//2、定义正则表达式
var reg_name = /^w{3,20}$/;
var flag = reg_name.test(name);
//3、判断
if(flag){
$("#name_msg").css("border","solid 1px green");
}else{
$("#name_msg").css("border","solid 1px red");
}
return flag;
}
function checktelephone() {
//1、获取telephone的值
var telephone = $("#telephone").val();
//2、定义正则表达式
var reg_telphone =/^1[34589][0-9]{9}$/;
//3、判断
var flag = reg_telphone.test(telephone);
if(flag){
$("#telephone").css("border","solid 1px green");