老师,我的问题是本节的4-8编程练习。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>4-8编程练习</title> <style type="text/css"> *{ padding:0; margin:0; } .wrap{ width:1000px; margin:0 auto; } h1{ width:960px; height: 80px; background-color: #0099cc; font-size: 18px; color:#fff; line-height: 80px; padding-left: 40px; } .register{ width: 1000px; background-color: #eee; height: 500px; position: relative; } .content{ width:1000px; position: absolute; top:50px; } .content .pstyle{ width: 1000px; color:#777; font-size: 18px; margin:0 auto; position: absolute; left:350px; } .pstyle1{ position: absolute; top:40px; } .pstyle2{ position: absolute; top:80px; } .pstyle3{ position: absolute; top:120px; } .pstyle4{ position: absolute; top:160px; } .pstyle5{ position: absolute; top:200px; } .pstyle6{ position: absolute; top:240px; } .pstyle7{ position: absolute; top:280px; } .pstyle8{ position: absolute; top:320px; } .pstyle9{ width:80px; height: 40px; background-color: #0099cc; border-radius: 3px; color:#fff; line-height: 40px; text-align: center; position: absolute; top:360px; left:400px; } </style> </head> <body> </body> <div class="wrap"> <h1>用户注册</h1> <div class="register" id="register"> <div class="content" id="content"> <table> <tr class="pstyle"> <td>用户名:</td> <td><input type="text" id="username"></p></td> </tr> <tr class="pstyle pstyle1"> <td>登录密码:</td> <td><input type="text" id="password"></p></td> </tr> <tr class="pstyle pstyle2"> <td>确认密码:</td> <td><input type="text" id="conpassword"></td> </tr> <tr class="pstyle pstyle3"> <td>姓名:</td> <td><input type="text" id="name"></td> </tr> <tr class="pstyle pstyle4"> <td>性别:</td> <td> <select name="sex" id="sex"> <option value="male">男</option> <option value="female">女</option> </select> </td> </tr> <tr class="pstyle pstyle5"> <td>身份证号码:</td> <td><input type="text" id="id"></td> </tr> <tr class="pstyle pstyle6"> <td>邮箱:</td> <td><input type="text" id="email"></td> </tr> <tr class="pstyle pstyle7"> <td>手机号码:</td> <td><input type="text" id="phone"></td> </tr> <!-- <tr class="pstyle pstyle8 pstyle9"> <td colspan="2">提交</td> </tr> --> </table> <p class="pstyle9" id="submit">提交</p> <!-- <p class="pstyle">用户名:<input type="text" id="username"></p> <p class="pstyle">登录密码:<input type="text" id="password"></p> <p class="pstyle">确认密码:<input type="text" id="conpassword"></p> <p class="pstyle">姓名:<input type="text" id="name"></p> <p class="pstyle"> 性别: <select name="sex" id="sex"> <option value="male">男</option> <option value="female">女</option> </select> </p> <p class="pstyle">身份证号码:<input type="text" id="id"></p> <p class="pstyle">邮箱:<input type="text" id="email"></p> <p class="pstyle">手机号码:<input type="text" id="phone"></p> <p class="pstyle pstyle1" id="submit">提交</p> --> </div> </div> </div> <script> var register = document.getElementById("register"), content = document.getElementById("content"), username = document.getElementById("username"), password = document.getElementById("password"), conpassword = document.getElementById("conpassword"), name = document.getElementById("name"), sex = document.getElementById('sex'), id = document.getElementById("id"), phone = document.getElementById("phone"), email = document.getElementById("email"), submit = document.getElementById("submit"); var pattern; submit.onclick = function (){ if(!justify.value){ alert("请输入正确的文本"); }else{ alert("您输入的文本都是正确的"); } } username.blur = function(){ pattern = new RegExp("^w+{6,20}$") username.value = pattern.exec("^w+{6,20}$") ? ok : '请输入6-20位的用户名'; } password.blur = function(){ pattern = new RegExp("^\s+{6,18}$") username.value = pattern.exec("^\s+{6,18}$") ? ok : '请输入6-18位的密码'; } conpassword.blur = function(){ pattern = new RegExp("^\s+{6,18}$") username.value = pattern.exec("^\s+{6,18}") ? ok : '请再次输入密码'; } name.blur = function(){ pattern = new RegExp("^w+{6,20}$") username.value = pattern.exec("^\u4e00-\u9fa5$") ? ok : '请输入2-4位的汉字'; } sex.blur = function(){ pattern = new RegExp("^男 女$") username.value = pattern.exec("^男 女$") ? ok : '请输入你的性别'; } id.blur = function(){ pattern = new RegExp("^\d+{15}|\d+{17}x$") username.value = pattern.exec("^\d+{15}|\d+{17}x$") ? ok : '请输入15位或者18位的数字'; } phone.blur = function(){ pattern = new RegExp("^\d+{11}$") username.value = pattern.exec("^\d+{11}$") ? ok : '请输入11位手机号'; } email.blur = function(){ pattern = new RegExp("^[a-z0-9]+(?:[.-_][a-z0-9]+)*@[a-z0-9]+([.-_][a-z0-9]+)*\.[a-z]{2,4}$") username.value = pattern.exec("^[a-z0-9]+(?:[.-_][a-z0-9]+)*@[a-z0-9]+([.-_][a-z0-9]+)*\.[a-z]{2,4}$") ? ok : '请输入您的邮箱'; } </script> </html>
请老师批改!
0
收起
正在回答
2回答
同学你好,首先老师没有偷懒哦,在第一条回答里面老师给出了思路,一般情况下,如果出现的问题比较多,说明同学这一块的知识掌握的都不是很不牢固,会给出思路,让同学自己先去实现,再提交,老师批复。如果错的点很少,可能说明是某个小知识点不牢固,会给出建议或者贴代码,如果老师把所有的代码都给同学,同学怎么能得到提升呢?对不对呀
老师以用户名为例,给同学举个例子:
布局:
js:
同学可以自己先写一写,如果哪个地方不会了,可以在问答区提问,老师帮助解决哒,加油加油~
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星