javascript regexp for numbers between 00-59 (seconds)

前端 未结 4 917
栀梦
栀梦 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:45

    If you want to make the tens digit optional, not the unit position, place the ? there:

    [0-5]?[0-9]
    

提交回复
热议问题