<html> <head> <meta http-equiv=Content-Type content="text/html;charset=utf-8"> <script type="text/javascript"> function a(obj){ var zhi=document.getElementById('a'); zhi.innerHTML=''; if(obj.value.length=='0'){ zhi.innerHTML='帳號不能爲空'; return false; exit; } else{ zhi.innerHTML='√'; return true; } alert("aaa"); } <!--驗證密碼--> function p(obj){ var zhi=document.getElementById('p'); if(obj.value.length=="0"){ zhi.innerHTML='密碼不能爲空'; return false; exit; }else{ zhi.innerHTML='√'; return true; } } <!--判斷兩次密碼是否一致--> function www(obj,obj2){ //alert('aa'); var a=document.getElementById('www'); a.innerHTML=''; if(obj.value!=obj2.value){ a.innerHTML='兩次密碼不一致'; return false; exit; }else{ a.innerHTML='√'; return true; } } </script> </head> <body> <form method="post" action="" name="myform"> 姓名:<input type="text" name="username" onblur="a(this)" /> <span id="a" style="color:red;font-size:12px;"></span><br> 密碼:<input type="password" name="pword" onblur="p(this)"/> <span id="p" style="color:red;font-size:12px;"></span></br> 確認密碼:<input type="password" name="qrpword" onblur="www(this,document.myform.pword)" /> <span id="www" style="color:red;font-size:12px;"></span></br> <input type="submit" value="提交"/> <input name="" type="button" class="userpsubmit" value="" id="add" onclick="check_all(document.myform)"> </form> </body> </html>