怪物猎人中的 角色:文本框字符长度限制的代码是什么?

来源:百度文库 编辑:高考问答 时间:2024/05/09 04:24:30
代码段如下:
<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="你的最大长度">