jsp中:
<textarea id="${msg.openId}" rows="2" style="display: none;height: 50;width: 99%"
onKeyUp="checkMaxInput(this)" onKeyDown="checkMaxInput(this)">
</textarea>
js中:
function checkMaxInput(txt)
{
if (txt.value.length > 666)
txt.value = txt.value.substring(0, 666);
}
本文介绍了如何在JS中通过函数限制文本输入框的输入长度不超过666个字符,使用了`substring`方法来实现这一功能。
746

被折叠的 条评论
为什么被折叠?



