jsp中如何判斷提交表單內的內容是否為空


function validate(){if (document.myform.username.value==""){alert("用戶名不能為空bai.");
document.myform.username.focus();
return false ;}if (document.myform.userpass.value==""){alert("密碼不能為空.");
document.myform.userpass.focus();
return false ;}
return true;}</script
jsp頁面代碼:du
<form action="conn.jsp" method="post" name="myform" id="myform"
<table width="44%" border="2" align="center" cellpadding="0" cellspacing="0"<tr<td width="33%"用戶名:</td
<td width="67%"<input type="text" name="username"</td</tr<tr<td密 碼:</td
<td<input type="password" name="userpass"</td</tr</table
<input type="submit" name="Submit" value="提交"</form在form里添加onsubmit="return validate()“,即改成:zhi
這樣就可以驗證所提交表dao單元素的值是否為空了……


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM