燃放鞭炮的利与弊论文:求助有关ASP中表单提交的限制问题?

来源:百度文库 编辑:神马品牌网 时间:2024/04/20 04:03:28
我想做一个基于asp的留言本,数据库为access的,我有2个框需要做限定
--------------------------------------------
1.昵称:这是个单行文本框,限定必须填写
2.留言栏:这是个多行文本域,限定有2个,首先必须填写,另外字数不能超过125。
--------------------------------------------
请问各位朋友,这个如何实现?请写出必要的程序和说明,因为小弟我这方面是新手,希望各位朋友能写详细点。谢谢!
感谢各位朋友帮我解答问题!真实太感谢你们了!

代码如下:

页面控件,表单名为form1>>

昵称:<input type="text" name="nickname">
留言栏:<textarea name="leaveword" rows="2" cols="20"></textarea>
''提交按钮
<input type="button" value="提交" onclick="check()">

然后写这个提交的方法:

<SCRIPT LANGUAGE="VBScript">
<!--
function check()
Dim n,l
Dim t
t = "我的留言板"
n = Trim(document.form1.nickname.value)
l = Trim(document.form1.leaveword.value)
If n = "" Then
msgbox "请输入您的昵称?",48,t
document.form1.nickname.focus()
exit function
End If
If l = "" Then
msgbox "请输入留言内容?",48,t
document.form1.leaveword.focus()
exit function
End If
If len(l) > 125 Then
msgbox "留言内容字数不要超过125个字?",48,t
exit function
End If
''如果验证成功,提交表单
document.form1.submit()
end function
//-->
</SCRIPT>

你把页面程序和相应的数据库发我邮箱里吧,压缩以后再发,我帮你看看.tjoy7d@126.com

<script language="JavaScript">
function checkText(ctext)
{
if(ctext.length==0)
return false;
else
return true;
}
function checkTextArea(ctextarea)
{
if(ctext.length==0)
{
alert("必须填写");
return false;
}
else if(ctext.length>125)
{
alert("字数不能超过125");
return false;
}
return true;
}
function isValid(form1)
{
if(!checkText(form1.单行文本框名字.value))
{
alert("必须填写");
form1.单行文本框名字.focus();
return false;
}
if(checkTextArea(form1.文本域名字.value))
return true;
else
return false;
}
</script>

han_wu_bing的回答
<form action=页面 onsubmit="retrun 函数名()"
...
</form>

<script language="JavaScript">
function CheckForm()
{

if (document.myform.username.value=="")
{
alert("不能为空!");
document.myform.username.focus();
return false;
}
if (document.myform.content.value=="")
{
alert("不能为空!");
document.myform.content.focus();
return false;
}
if (document.myform.content.value.length>125)
{
alert("字数不能超过125");
document.myform.content.focus();
return false;
}
return true;
}

</script>
<form method="POST" name="myform" onSubmit="return CheckForm();" action="?">
昵称:<input type="text" name="username">
留言栏:<textarea name="content" rows="2" cols="20"></textarea>

<input type="submit" value="提交">

</form>