實現對數據的校驗並提示
阿新 • • 發佈:2017-10-22
1.0 nbsp lns document ans element utf-8 rip img
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>
實現對數據的校驗並提示