這個題目我做出來 了,只是這樣的話,就算寫了密碼,還是不能按確定按鈕提交,鼠標一移到確定按鈕就彈出窗口?。?!
難道說只是為了練習
難道說只是為了練習
2016-08-08
一般都是提交的時候在驗證吧
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"> <title>表單列表</title> <script?type="text/javascript"> //?驗證輸入不為空的腳本代碼 function?checkForm(form)?{ if(form.username.value?==?"")?{ alert("用戶名不能為空!"); form.username.focus(); return?false; } if(form.password.value?==?"")?{ alert("密碼不能為空!"); form.password.focus(); return?false; } return?true; } </script> </head> <body> ????<form?method="post"?action="save.php"??onsubmit="return?checkForm(this);"> ???????<label?for="username">用戶名:</label> ???????<input?type="text"?name="username"?id="username"?valve=""><br/> ???????<label?for="password">密碼</label> ???????<input?type="password"name="username"?id="username"?valve=""><br/> ???????<input?type="submit"?name="確定"?id="submit"?valve=""> ???????<input?type="reset"?name="充值"?id="reset"?valve=""> ??????? ????</form> </body> </html>
所以說沒任何叼用
onmosuover的意思就是當鼠標經(jīng)過時觸發(fā)事件
其他部分的代碼都是無用的
就是讓你看onmouseover的效果
所以輸入密碼和提交部分都是沒用的
逗著玩咯
舉報
2016-08-13
當然這里代碼的主要意圖是認識onmouseover事件,確實是只為了練習。
實際情況當然不會這么設(shè)計:會在彈出對話框之前進行判斷,如果已經(jīng)輸入了內(nèi)容,就不再彈出提示,此時可按下鼠標左鍵,確認提交。