小编Nur*_*lam的帖子

如何在html文本框中只允许4位数字?

我试图限制HTML文本框中的用户只插入4位数字0-9.

我尝试了如下,但它仅限于允许两位数字.

<input type="text"  name="pincode" maxlength="4"  id="pin" pattern="^0[1-9]|[1-9]\d$" required/>
Run Code Online (Sandbox Code Playgroud)

html regex

11
推荐指数
4
解决办法
5万
查看次数

标签 统计

html ×1

regex ×1