gpt4 book ai didi

angularjs - 使用 ng-pattern 对字符串进行数字验证

转载 作者:行者123 更新时间:2023-12-02 15:16:23 25 4
gpt4 key购买 nike

我需要对字符串进行数字验证(即 type="text")

<input type="text" min="1" max="5" ng-pattern="/^[0-9]+$/" required />

最佳答案

试试这段代码,不能输入字符串,只能输入数字

<input type="text" min="1" max="5" onkeypress='return event.charCode >= 48 && event.charCode <= 57' required />

关于angularjs - 使用 ng-pattern 对字符串进行数字验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40124513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com