<form action="" method="post" onSubmit="chkform(this)"> //或者<form name=formname action="" method="post" onSubmit="chkform(formname)"> action里面填写要提交的页面 <table width="495" height="278" border="0" cellpadding="3" cellspacing="0" bgcolor="#CCCCCC"> <tr bgcolor="#FFFFFF"> <td width="110" align="right">您的姓名:</td> <td width="373"><input name="GuestName" type="text" id="GuestName" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="12"> <font color="#FF0000"> *</font></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">公司名称:</td> <td><input name="CompanyName" type="text" id="CompanyName" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="30"> <font color="#FF0000">*</font></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">咨询主题:</td> <td><input name="GuestTitle" type="text" id="GuestTitle" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="30"> <font color="#FF0000"> *</font></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">联系电话:</td> <td><input name="GuestTel" type="text" id="GuestTel" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="20"> <font color="#FF0000"> *</font></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">手 机:</td> <td><input name="GuestMobil" type="text" id="GuestMobil" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #?瀱?潳楬d????昀?ぢ9慡?朮晩??牔浩?摩猨牴偉摁牤??师?000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="20"> </td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">联系地址:</td> <td><input name="GuestAddress" type="text" id="GuestAddress" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">电子邮箱:</td> <td><input name="GuestEmail" type="text" id="GuestEmail" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid" size="20"> <font color="#FF0000"> *</font></td> </tr> <tr bgcolor="#FFFFFF"> <td align="right">咨询内容:</td> <td><textarea name="GuestContent" cols="55" rows="7" id="GuestContent" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"></textarea> <font color="#FF0000"> *</font></td> </tr> <tr align="center" bgcolor="#FFFFFF"> <td height="45" colspan="2"><input type="submit" name="Submit2" value="提交咨询"> </td> </tr> </table>
</form>
<!--#include file="Conn.asp" --> <!--#include file="Admin/Inc/Const.asp" --> <% Set Rs=server.CreateObject("adodb.recordset") Rs.activeconnection=conn If Trim(Request("action"))="add" Then GuestName=Replace(Trim(Request("GuestName")),"'","") If Trim(GuestName)="" Then Call CLoseConn(Conn) Msgstr="姓名不能为空" msg(Msgstr) Back Response.end End if CompanyName=Replace(Trim(Request("CompanyName")),"'","") GuestTitle=Replace(Trim(Request("GuestTitle")),"'","") GuestTel=Replace(Trim(Request("GuestTel")),"'","") If GuestTel="" Then Call CLoseConn(Conn) Msgstr="联系电话不能为空" msg(Msgstr) Back Response.end End if GuestMobil=Replace(Trim(Request("GuestMobil")),"'","") GuestAddress=Replace(Trim(Request("GuestAddress")),"'","") GuestEmail=Replace(Trim(Request("GuestEmail")),"'","") GuestContent=Replace(Replace(Request("GuestContent"),"'",""),vbcrlf,"<br>") If Trim(GuestContent)="" Then Call CLoseConn(Conn) Msgstr="留言内容不能为空" msg(Msgstr) Back Response.end End if sql="insert into TbGuest(GuestName,CompanyName,GuestTitle,GuestTel,GuestMobil,GuestAddress,GuestEmail,GuestContent) " Sql=Sql&" values('"&GuestName&"','"&CompanyName&"','"&GuestTitle&"','"&_ GuestTel&"','"&GuestMobil&"','"&GuestAddress&"','"&GuestEmail&"','"&GuestContent&"')" Conn.Execute(Sql) Call CloseConn(Conn) Msgstr="新增成功" Msg(Msgstr) Redirect("inqu.asp") Response.end End if %> <script language="JavaScript"> function chkform(formobj){ if(formobj.GuestName.value.replace(/^\s*/,'').replace(/\s*$/,'')==""){ alert("姓名不能为空") formobj.GuestName.focus() return false } if(formobj.GuestTel.value.replace(/^\s*/,'').replace(/\s*$/,'')==""){ alert("联系电话不能为空") formobj.GuestTel.focus() return false } if(formobj.GuestContent.value.replace(/^\s*/,'').replace(/\s*$/,'')==""){ alert("信的内容不能为空") formobj.GuestContent.focus() return false } return true } </script>