<! DOCTYPE html >
< html lang = " en" >
< head> < meta charset = " UTF-8" > < title> 注册</ title> < style> * { margin : 0px; padding : 0px; box-sizing : border-box; } body { background : url ( "image/bjt01.jpg" ) no-repeat center; background-size : cover; } .layout { width : 900px; height : 500px; border : 8px solid #EFFBFB; background-color : white; margin : 110px auto auto auto; } .div-left { float : left; margin : 15px; } .div-center { float : left; } .div-right { float : right; margin-top : 20px; margin-right : 20px; } .div-left > p:first-child { color : #facb48; font-size : 20px; } .div-left > p:last-child { color : #ABADAF; font-size : 20px; } .div-right > p { font-size : 15px; } .div-right p a { color : pink; } .div-center { width : 520px; margin-top : 10px; } .td-left { width : 110px; text-align : right; height : 45px; } .td-right { padding-left : 20px; } #userName, #password, #email, #realName, #phoneNumber, #birthday, #verCode { width : 251px; height : 32px; border : 1px solid #E6EAED; padding-left : 10px; border-radius : 5px; vertical-align : middle; } #verCode { width : 120px; margin-right : 20px; } #img-check { vertical-align : middle; height : 32px; } #sub-btn { width : 150px; height : 40px; background-color : #facb48; border : 1px solid #facb48; } input::-webkit-input-placeholder { color : #ccc; } .error { font-size : 15px; color : red; margin-left : 10px; } .tick { vertical-align : middle; width : 25px; height : 25px; } .div-right, .div-center, .td-right, .td-left, .td-btn { } #td-btn { padding-left : 130px; } #sub-btn { margin-top : 20px; } </ style> < script !src = " " > window. onload = function ( ) { document. getElementById ( "form" ) . onsubmit = function ( ) { return checkUsername ( ) && checkPassword ( ) && checkPhoneNumber ( ) && checkEmail ( ) && checkVerCode ( ) ; } ; document. getElementById ( "userName" ) . onblur = function ( ) { checkUsername ( ) ; } ; document. getElementById ( "password" ) . onblur = function ( ) { checkPassword ( ) ; } ; document. getElementById ( "phoneNumber" ) . onblur = function ( ) { checkPhoneNumber ( ) ; } document. getElementById ( "email" ) . onblur = function ( ) { checkEmail ( ) ; } document. getElementById ( "verCode" ) . onblur = function ( ) { checkVerCode ( ) ; } } ; function checkUsername ( ) { var userName = document. getElementById ( "userName" ) . value; var regUserName = / ^\w{6,12}$ / ; var flag = regUserName. test ( userName) ; if ( flag) { document. getElementById ( "prompt-un" ) . innerHTML = "<img class='tick' src='image/tick.png'/>" ; } else { document. getElementById ( "prompt-un" ) . innerHTML = "用户名格式错误!" ; } return flag; } function checkPassword ( ) { var password = document. getElementById ( "password" ) . value; var regPassword = / ^\w{6,12}$ / ; var flag = regPassword. test ( password) ; if ( flag) { document. getElementById ( "prompt-pw" ) . innerHTML = "<img class='tick' src='image/tick.png'/>" ; } else { document. getElementById ( "prompt-pw" ) . innerHTML = "密码格式错误!" ; } return flag; } function checkEmail ( ) { let flag = true ; let email = document. getElementById ( "email" ) . value; if ( ! email) { return flag; } let regEmail = / ^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$ / ; flag = regEmail. test ( email) ; if ( flag) { document. getElementById ( "prompt-email" ) . innerHTML = "<img class='tick' src='image/tick.png'/>" ; } else { document. getElementById ( "prompt-email" ) . innerHTML = "邮箱格式错误" ; } } function checkPhoneNumber ( ) { var flag = true ; var phoneNumber = document. getElementById ( "phoneNumber" ) . value; if ( ! phoneNumber) { return flag; } var regPhoneNumber = / (\+86)?1\d{10} / ; flag = regPhoneNumber. test ( phoneNumber) ; if ( flag) { document. getElementById ( "prompt-pn" ) . innerHTML = "<img class='tick' src='image/tick.png'/>" ; } else { document. getElementById ( "prompt-pn" ) . innerHTML = "手机号格式错误" ; } return flag; } function checkVerCode ( ) { let verCode = document. getElementById ( "verCode" ) . value; let regVerCode = / ^[\d\a]{6}$ / ; let flag = regVerCode. test ( verCode) ; if ( flag) { document. getElementById ( "prompt-vc" ) . innerHTML = "<img class='tick' src='image/tick.png'/>" ; } else { document. getElementById ( "prompt-vc" ) . innerHTML = "验证码格式错误" ; } return flag; } </ script> </ head>
< body>
< div class = " layout" > < div id = " div_left" class = " div-left" > < p class = " title-en" > 新用户注册</ p> < p class = " title-zh" > USER REGISTER</ p> </ div> < div id = " div_center" class = " div-center" > < form id = " form" action = " #" method = " get" > < table> < tr> < td class = " td-left" > < label for = " userName" > 用户名</ label> </ td> < td class = " td-right" > < input type = " text" name = " userName" id = " userName" placeholder = " 请输入用户名" > < spanid = " prompt-un" class = " error" > </ span> </ td> </ tr> < tr> < td class = " td-left" > < label for = " password" > 密码</ label> </ td> < td class = " td-right" > < input type = " text" name = " password" id = " password" placeholder = " 请输入密码" > < spanid = " prompt-pw" class = " error" > </ span> </ td> </ tr> < tr> < td class = " td-left" > < label for = " email" > Email</ label> </ td> < td class = " td-right" > < input type = " email" name = " email" id = " email" placeholder = " 请输入邮箱" > < spanid = " prompt-email" class = " error" > </ span> </ td> </ tr> < tr> < td class = " td-left" > < label for = " realName" > 姓名</ label> </ td> < td class = " td-right" > < input type = " text" name = " realName" id = " realName" placeholder = " 请输入姓名" > </ td> </ tr> < tr> < td class = " td-left" > < label for = " phoneNumber" > 手机号</ label> </ td> < td class = " td-right" > < input type = " text" name = " phoneNumber" id = " phoneNumber" placeholder = " 请输入手机号" > < span id = " prompt-pn" class = " error" > </ span> </ td> </ tr> < tr> < td class = " td-left" > 性别</ td> < td class = " td-right" > < input type = " radio" value = " 0" > 男 < input type = " radio" value = " 1" > 女</ td> </ tr> < tr> < td class = " td-left" > 出生日期</ td> < td class = " td-right" > < input type = " date" name = " birthday" id = " birthday" > </ td> </ tr> < tr> < td class = " td-left" > < label for = " verCode" > 验证码</ label> </ td> < td class = " td-right" > < input type = " text" name = " verCode" id = " verCode" placeholder = " 请输入验证码" > < imgid = " img-check" src = " image/ver_code.png" /> < span id = " prompt-vc" class = " error" > </ span> </ td> </ tr> < tr> < td colspan = " 2" id = " td-btn" class = " td-btn" > < input type = " submit" value = " 注册" id = " sub-btn" > </ td> </ tr> </ table> </ form> </ div> < div id = " div-right" class = " div-right" > < p> 已有账号?< a href = " #" > 立即登录</ a> </ p> </ div>
</ div>
</ body>
</ html>