函数|文本框
<%
Function RequestText(TextString,TextType,TextName,TextNumberMost,TextNumberLeast)
'TextString获取文本框内的值
'TextType设定文本框名称的类型,如input为0,textarea为1
'TextName碰到错误时显示的名称
'TextNumberMost文本框能填入的字节最大数
'TextNumberLeast文本框能填入的字节最小数
GetText=Request(TextString)
Select Case TextType
Case 0
GetText=Replace(GetText,"<","<")
GetText=Replace(GetText,">",">")
GetText=Replace(GetText,"'","''")
if Len(GetText)>TextNumberMost then
Response.Write("<Script>alert(""您在 "&TextName&" 项输入字节超过最大字节"&TextNumberMost&",请返回重新输入!"");history.go(-1)</script>")
Response.End
Elseif Len(GetText)<TextNumberLeast then
Response.Write("<Script>alert(""您在 "&TextName&" 项输入字节小于了最小字节"&TextNumberLeast&",请返回重新输入!"");history.go(-1)</script>")
Response.End
End if
Case 1
GetText=Replace(GetText,"<","<")
GetText=Replace(GetText,">",">")
GetText=Replace(GetText,"'","''")
GetText=Replace(GetText," "," ")
GetText=Replace(GetText,vbCrlf,"<br />")
if Len(GetText)>TextNumberMost then
Response.Write("<Script>alert(""您在 "&TextName&" 项输入字节超过最大字节"&TextNumberMost&",请返回重新输入!"");history.go(-1)</script>")
Response.End
Elseif Len(GetText)<TextNumberLeast then
Response.Write("<Script>alert(""您在 "&TextName&" 项输入字节小于了最小字节"&TextNumberLeast&",请返回重新输入!"");history.go(-1)</script>")
Response.End
End if
End Select
RequestText=GetText
End Function
%>
<%
'例子
if Request("post")<>"" then
Name=RequestText("Name",0,"姓名",10,2)
Text=RequestText("Text",0,"内容",255,0)
Response.Write "姓名值为:"&Name&"<br>内容值为:"&Text
End if
%>
<form method="GET">
<p>姓名<input type="text" name="name" size="20"></p>
<p>内容<textarea rows="6" name="text" cols="20"></textarea><input type="submit" value="提交" name="post">
<input type="reset" value="重置" name="B2"></p>
</form>