javascript regexp for numbers between 00-59 (seconds)

前端 未结 4 954
栀梦
栀梦 2021-01-19 15:03

I want to check if a field is a valid time value (just seconds). So I want to accept the numbers from 0 to 59. I came out with this:

[0-5][0-9]?
4条回答
  •  温柔的废话
    2021-01-19 15:50

    This should be sufficient: [0-5]?\d

    However if you want to enforce two digits (ie. 01, 02...) you should just use [0-5]\d

提交回复
热议问题