1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>无标题文档</title>
6 </head>
7
8 <body>
9 <div align="center">
10 <table>
11 <tr>
12 <td>用户名:</td><td><input onfocus="ffocus()" onblur="bblur(this)" type="text" id="uerName"/></td><td id="mess" ></td>
13 </tr>
14
15 </table>
16
17 </div>
18 </body>
19 <script>
20 function ffocus(){
21 document.getElementById("mess").innerHTML="用户名必须是3-6个字符";
22
23 }
24 function bblur(t){
25 var userName=t.value;
26 alert(userName.length);
27 if(userName.length>=3&&userName.length<=6){
28 document.getElementById("mess").innerHTML="<img width='100px' height='50px' src='正确.png' >";
29
30 }else{
31 document.getElementById("mess").innerHTML="<img width='100px' height='50px' src='错误.png' >";
32
33 }
34
35 }
36 </script>
37 </html>