如何检测表单信息不为空呢?

来源:百度知道 编辑:UC知道 时间:2024/05/23 13:55:13
程序是这样的,可是就是不能检测,不知道哪里出问题了.
<form action="save.asp?act=add" method="post" enctype="multipart/form-data" name="form1" onSubmit="return checkform()">
<table>
<tr>
<td width="121" bgcolor="#f5f6fb"><div align="right">姓 名:</div></td>
<td width="556" bgcolor="#f5f6fb"><input name="name0" type="text" size="20" /></td>
</tr>
</table>
</form>

<script language="JavaScript">

function checkform(){

if (document.form1.name0.value==""){
alert("姓名不能为空!请填写!");
document.form1.name0.focus();
return false;
}
</SCRIPT>
function checkform(){

if (document.form1.nam

楼上的兄弟,无论你的程序对与否,都不行,因为你是在客服端进行的检测,如果遇到不怀好意的人可能自己做一个表单,向服务器提交空数据,此时就会出错,安全措施不好的服务器会输出详细的出错信息,如果你的数据库该项值不允许是空,你数据库就被别人盗走了,即使重要数据你用了MD5加密,除非特别复杂,很多是可以破解的,如果你的网站有会员,他们的密码不可能都很复杂,且有的人,邮箱QQ的帐号密码都相同。危险啊!最好在服务器端取得数据后用 if len(string)=0
或者if string="" or string=empty

程序是这样的,可是就是不能检测,不知道哪里出问题了.
<form action="save.asp?act=add" method="post" enctype="multipart/form-data" name="form1" onSubmit="return checkform()">
<table>
<tr>
<td width="121" bgcolor="#f5f6fb"><div align="right">姓 名:</div></td>
<td width="556" bgcolor="#f5f6fb"><input name="name0" type="text" size="20" /></td>
</tr>
</table>
</form>

<script language="JavaScript">

function checkform(){

if (document.form1.na