Check if a textbox contains numbers only

后端 未结 5 1742
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 06:38

How to check if a textbox contains numbers only?

While googling I came across this. But I\'m wondering if isNumeric can be used for this purpose or if t

5条回答
  •  醉梦人生
    2020-12-10 07:10

    There're many ways, you can use isNaN

     isNaN(VALUE);
    

    You can also use regEx to verify numeric values.

    console.log(/^\d+$/.test(VALUE));
    

提交回复
热议问题