checking if number entered is a digit in jquery

前端 未结 10 1723
遥遥无期
遥遥无期 2020-12-01 01:19

I have a simple textbox in which users enter number.
Does jQuery have a isDigit function that will allow me to show an alert box if users ente

10条回答
  •  情深已故
    2020-12-01 01:54

    Value validation wouldn't be a responsibility of jQuery. You can use pure JavaScript for this. Two ways that come to my mind are:

    /^\d+$/.match(value)
    Number(value) == value
    

提交回复
热议问题