如何限制或限制用户在文本框中最多只能输入五个字符?
下面是作为我表单一部分的输入字段:
<input type="text" id="sessionNo" name="sessionNum" />
它是否使用类似 maxSize 之类的东西?
最佳答案
The maximum number of characters that will be accepted as input. This can be greater that specified by SIZE , in which case the field will scroll appropriately. The default is unlimited.
<input type="text" maxlength="2" id="sessionNo" name="sessionNum" onkeypress="return isNumberKey(event)" />
但是,这可能会或可能不会受到您的处理程序的影响。您可能还需要使用或添加另一个处理函数来测试长度。
关于html - 限制表单输入文本字段中允许的字符数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8545376/