限制输入长度问题?

evilzydar 2004-05-10 02:26:01
我想限制输入字节的长度为两位而且只能为两位,请问怎么做????
...全文
67 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
SaySorry 2004-05-10
  • 打赏
  • 举报
回复
对不起
<input type="text" name="textfield" maxlength="2">
<script language=vbscript>
sub haha()
if lenB(textfield.value) <>2then
alert "重新输入"
……
end if
end sub
</script>
SaySorry 2004-05-10
  • 打赏
  • 举报
回复
<input type="text" name="textfield" maxlength="2">
<script language=vbscript>
sub haha()
if (textfield.value) <>2then
alert "重新输入"
……
end if
end sub
</script>
dyy0355 2004-05-10
  • 打赏
  • 举报
回复
在dreamvear中,那里有“最多字符”一项,在其中输入2就可以了
pingzi3000 2004-05-10
  • 打赏
  • 举报
回复
//函数作用:检测文本框字符长度
//变量声明:widgetName:控件名;widgetLimitLength:控件限定长度;widgetSpec:控件说明文字
function CheckStrLength(widgetName,widgetLimitLength,widgetSpec)
{
var widgetValue=document.all(widgetName).value;
//正则表达式说明:g参数代表全局匹配,中文编码位于x00至xff,正则表达作用在于替换掉文本框中的中文字符
var widgetStrTrueLeng = widgetValue.replace(/[^\x00-\xff]/g,"~~").length;
var overLength=widgetStrTrueLeng-widgetLimitLength;
if(widgetStrTrueLeng>widgetLimitLength)
{
alert("【 "+widgetSpec+" 】长度不得超过"+widgetLimitLength+"个字符或者"+widgetLimitLength/2+"个汉字\n\n现已超出"+overLength+"个字符");
document.all(widgetName).focus();
return false;
}
else
{
return true;
}
}
cmy3918 2004-05-10
  • 打赏
  • 举报
回复
<input type="text" name="textfield" maxlength="2">
evilzydar 2004-05-10
  • 打赏
  • 举报
回复
我的意思是直接在输入框中做限制<input type=text name="input">
就是在text框中只能输入2位字节,不能超过2位
csdnzheman 2004-05-10
  • 打赏
  • 举报
回复
楼上正解!

changd=lent("str")
if changd <> 2 then
.......//
end if
skyboy0720 2004-05-10
  • 打赏
  • 举报
回复
len(str)=2?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧