【问题标题】:how to limit an text field to a certain amount of letters?如何将文本字段限制为一定数量的字母?
【发布时间】:2013-07-07 22:21:38
【问题描述】:

我的网站上有一个文本字段,我不想限制我的用户在其中写入超过 2 个字母。

<label>Text</label>
<input type='text' id='changeText' name='changeText'>

【问题讨论】:

标签: javascript html input field


【解决方案1】:
<input type='text' id='changeText' name='changeText' maxlength="2">

使用最大长度属性

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    • 2019-12-28
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    • 2013-05-25
    相关资源
    最近更新 更多