关于表单检测是否为空的问题
表单部分代码:
<form method="post" action="savedata.asp" name="guestbook" onsubmit="return check(this)">
<div align="center">
<center>
<table width="556" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" height="20">
<!-- #include file="bar.asp" -->
</td>
</tr>
</table>
<table border="0" cellspacing="0" width="522" cellpadding="0" height="364">
<tr>
<td height="20" bgcolor="<%=bgcolor1%>" style="border-top:<%=tablecolor%> 1px solid;border-left:<%=tablecolor%> 1px solid;border-right:<%=tablecolor%> 1px solid;">
<div align="center"><center>
<p><strong><font color="#0099CC">请 您 留 言</font></strong>
</center></div></td>
</tr>
<tr align="center">
<td height="329" valign="top" align="middle">
<div align="center"><center>
<table
border="0" cellpadding="0" width="522" height="310" cellspacing="0">
<tr>
<td width="94" height="25" class="td1">
<div align="right"> <font color="#0080C0" size="2">名 字:</font>
</div>
</td>
<td width="414" height="25" class="td6"><font> </font>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td><font>
<input class="smallInput" name="name" size="20">
</font></td>
</tr>
</table></form>
检测表单是否为空代码:
<script language=javascript>
function check(theform)
{ var mystr1,mystr2,mylen,qqnum,qqlen,qqs;
mystr1=this.guestbook.email.value;
mylen=mystr1.length-5;
mystr2=mystr1.substring(1,mylen);
resultmy=mystr2.match("@");
qqnum=this.guestbook.qq.value
qqlen=qqnum.length
for(i=0;i<=qqlen;i++)
{qqs=qqnum.charAt(i)
if(qqs>=0 && qqs<=9)
{}
else
{alert('错误的QQ号码');
this.guestbook.qq.focus();
this.guestbook.qq.select();
return (false);
break;
}
}
if (this.guestbook.name.value=="")
{alert('请写上你的名字');
this.guestbook.name.focus();
return (false);
}
if (this.guestbook.email.value!="")
{
if (resultmy!="@")
{alert('请正确填写你的email地址');
this.guestbook.email.focus();
this.guestbook.email.select();
return (false);
}
}
for(i=0;i<=qqlen;i++)
{qqs=qqnum.charAt(i)
if(qqs>=0 && qqs<=9)
{}
else
{alert('错误的QQ号码');
this.user.qq.focus();
this.user.qq.select();
return (false);
break;
}
}
if (this.guestbook.title.value=="")
{alert('请写上主题');
this.guestbook.title.focus();
this.guestbook.title.select();
return (false);
}
}
</script>
在这边我有几个疑问:
一,在表单ACTION后面on submint跟的是return check(this), 可下面检测的代码又没有定义this这个参数?
二,检测的代码定义检测的表单为the from 又不是表单上面所定义的表单名guestbook?
这是为什么呢??
帮我分析一下谢谢.