Check if a textbox contains numbers only

后端 未结 5 1843
佛祖请我去吃肉
佛祖请我去吃肉 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:29

    You can match the value of text box against the numeric regression to check if it contains numbers only or not, Like below code...

    if($('#myText').val().match(/^\d+$/)){
    // Your code here
    }
    

提交回复
热议问题