成都地铁6号线通车时间:文本框字符长度限制的代码是什么?

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 08:21:47
代码段如下:
<input type="text" name="txt" size="20">
请各位高手回答的时候根据提供的代码段写代码。谢谢各位。

限制文本框字符长度的代码是:
if(document.form.mobile.value=="")
{
alert("您输入错误");
document.forma.mobile.focus();
return false;
}
else
{
if(!/^\d{11}$.test(document.form.mobile.value))
{alert("您输入数字的位数不对");
document.forma.mobile.focus();
return false;
}
}

<input type="text" name="txt" size="20" maxlength="你的最大长度">