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