ASP限制输入字数在5-100之间

来源:百度知道 编辑:UC知道 时间:2024/06/15 06:03:01
请高手帮忙,添加限制语句,把字数限制5——100之间,谢谢!
<%if request("submitok")="" then%>
<table width="394" border="0" cellpadding="0" cellspacing="0" >
<form action="u_trueuser.asp?submitok=ok" method="post">
<tr>
<td width="5" rowspan="2"><img src="images/j_top_left.gif" width="5" height="4"><img src="images/j__.gif" width="4" height="100"><img src="images/j_left_bottom.gif" width="5" height="4"></td>
<td align="center" bgcolor="F7F7F7" style="border-top:#cccccc 1px solid;border-bottom:#cccccc 1px solid;"><select name="kind" id="kind">
<option value="诚信会员" selected>诚信会员</option>

js限制输入的...

<script type="text/javascript">
function fucCheckLength(string strTemp)
{
var i,sum;
sum=0;
for(i=0;i<strTemp.length;i++)
{
if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
sum=sum+1;
else
sum=sum+2;//汉字占有两个字符
}
return sum;
}
function ShowLeft(){
var LenString,LenStringI,Strings;
LenString=fucCheckLength(document.getElementById("TextBox1").value);
LenStringI=LenString;
if (LenString>120){
alert("输入的字符长度不能超过100(汉字50个)!");
Strings=document.getElementById("TextBox1").value;
while(LenStringI>100){//超过100个字符时候的处理方式