在線留言板加了js驗證,把代碼加到留言板模板里面
? <SCRIPT language=JavaScript1.2>
function check(theForm,textlengh) {
??
?if(theForm.name.value == "") {
??alert("對不起!您的姓名不能為空!");
??return false;
?}
?if (theForm.call.value.length == ""){
??alert("對不起!您的電話不能為空!");
??return false;
?}?
?if(theForm.email.value == "") {
??alert("對不起!電子郵件不能為空!");
??return false;
?}
?if (theForm.content.value.length == ""){
??alert("對不起!咨詢或建議不能為空!");
??return false;
?}?
?if(theForm.lytext.value.length > textlengh) {
??alert("對不起!咨詢或建議長度不能超過" + textlengh + "字符!");
??return false;
?}
}
</SCRIPT>
????? <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
??????? <TBODY>
??????? <TR>
????????? <TD>
??????????? <P align=center><FONT face=宋體 color=#000000
????????? size=3></FONT> </P></TD></TR></TBODY></TABLE><BR>
????? <TABLE cellSpacing=1 cellPadding=0 width="80%" align=center
????? bgColor=#cccccc border=0>
?????? ????????<form action="../../enews/index.php" method="post" name="form1" id="form1">
??????? <TBODY>
??????? <TR align=middle bgColor=#eeeeee>
????????? <TD colSpan=2 height=24><FONT color=#000000>在線留言</FONT></TD></TR>
???????
??????? <TR>
????????? <TD align=right width="29%" bgColor=#ffffff height=26><FONT
??????????? color=#000000>您的姓名:</FONT></TD>
????????? <TD width="71%" bgColor=#ffffff height=24> <INPUT maxLength=15
??????????? size=30 name=name> <FONT color=#ff0000>*</FONT> </TD></TR>
??????? <TR>
????????? <TD align=right bgColor=#ffffff height=26><FONT
??????????? color=#000000>您的電話:</FONT></TD>
????????? <TD bgColor=#ffffff height=24> <INPUT maxLength=15 size=30
??????????? name=call> <FONT color=#ff0000>*</FONT> </TD></TR>
??????? <TR>
????????? <TD align=right bgColor=#ffffff height=26><FONT
??????????? color=#000000>電子郵件:</FONT></TD>
????????? <TD bgColor=#ffffff height=24> <INPUT maxLength=50 size=30
??????????? name=email> <FONT color=#ff0000>*</FONT> </TD></TR>
??????? <TR>
????????? <TD align=right bgColor=#ffffff height=24><FONT
??????????? color=#000000>咨詢或建議:</FONT></TD>
????????? <TD bgColor=#ffffff height=24> <TEXTAREA name=lytext rows=5 cols=29></TEXTAREA>
??????????? <FONT color=#ff0000>*</FONT> </TD></TR>
??????? <TR bgColor=#ffffff>
????????? <TD align=middle colSpan=2 height=30><INPUT onClick="return check(this.form,'200')" type=submit value="提 交" name=Submit3>
<INPUT type=reset value="重 置" name=Submit2> <input name="enews" type="hidden" id="enews" value="AddGbook" />
????? </TD></TR></FORM></TBODY></TABLE>