gpt4 book ai didi

javascript - 使用 Charcode 在输入字段中接受数字特殊字符和逗号

转载 作者:行者123 更新时间:2023-12-03 02:27:33 32 4
gpt4 key购买 nike

我使用字符代码,以便用户只能输入数字、特殊字符和逗号。

<input type="text" class="form-control numOnly" 
onkeypress="return event.charCode >= 48 &amp;&amp; event.charCode <= 57">

现在它只接受数字,但我想允许使用字符代码使用特殊字符和逗号。

我错过了什么?

最佳答案

尝试下面

<input type="text" class="form-control numOnly" onkeypress="return event.charCode >= 32 && event.charCode <= 57">

关于javascript - 使用 Charcode 在输入字段中接受数字特殊字符和逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48881478/

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