本帖最后由 Nocturne 于 2013-10-2 23:13 编辑
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>无标题文档</title>
- <script type="text/javascript" src="doctool.js"></script>
- <style type="text/css">
- #useryes,#userno{
- display:none;
- }
- </style>
- <script>
- function checkUser(userNode){
- var name= userNode.value;
- var namereg = new RegExp("^[a-zA-z][a-zA-Z0-9_]{0,9}[ DISCUZ_CODE_0 ]quot;);
- var spanNode1 = byId("useryes");
- var spanNode2 = byId("userno");
- if(name.match(namereg)){
- spanNode1.style.display = "inline";
- spanNode1.style.color = "green";
- spanNode2.style.display = "none";
- }else{
- spanNode2.style.display = "inline";
- spanNode2.style.color = "red";
- spanNode1.style.display = "none";
- }
- }
- function checkPsw(pswNode){
- var pass = pswNode.value;
- var passreg = new RegExp("^[0-9]{5}[ DISCUZ_CODE_0 ]quot;);
- var spanNode = byId("pswspan");
- if(pass.match(passreg)){
- spanNode.innerHTML = "密码正确".fontcolor("green");
- }else{
- spanNode.innerHTML = "密码错误".fontcolor("red");
- }
-
- }
- </script>
- </head>
- <body>
- <div>
- <form action="">
- <table align="center" >
- <tr>
- <td>用户名:</td>
- <td><input type="text" name="username" onBlur="checkUser(this)"/>
- <span id="useryes">用户名正确</span>
- <span id="userno">用户名错误</span>
- </td>
- </tr>
- <tr>
- <td>密码:</td>
- <td><input type="password" name="psw" onclick="checkPsw(this)"/>
- <span id="pswspan"></span>
- </td>
- </tr>
- <tr>
- <td>确认密码:</td>
- <td><input type="password" name="password2"/></td>
- </tr>
- <tr><td>性别:</td>
- <td>男<input type="radio" name="sex" value="男"/>女<input type="radio" name="sex" value="女"/></td>
- </tr>
- <tr>
- <td>爱好:</td>
- <td><input type="checkbox" name="hobby" value="sport" />运动
- <input type="checkbox" name="hobby" value="game" />玩游戏
- <input type="checkbox" name="hobby" value="tenlent" />聊天
- </td>
- </tr>
- <tr>
- <td>城市:</td>
- <td>
- <select name = "city">
- <option value="1">北京</option>
- <option value="2">上海</option>
- <option value="3">广州</option>
- </slect>
- </td>
- </tr>
- <tr><td>个人间介</td>
- <td><textarea rows="10" cols="30"></textarea></td>
- </tr>
- </table>
- </form>
- </div>
- </body>
复制代码 最后提示用户名是否正确和密码是否正确的时候为什么是显示1行,我认为密码输入多次的时候应该留下上次的痕迹啊为什么没有了呢?
求指点 |