RegEx - Time Validation ((h)h:mm)

后端 未结 6 1656
春和景丽
春和景丽 2021-02-13 12:46
/^\\d{1,2}[:][0-5][0-9]$/

is what I have. this limits minutes to 00-59. It does not, however, limit hours to between 0 and 12. For similarity and unifo

6条回答
  •  情深已故
    2021-02-13 13:05

    Thanks!!! I use this Javascript code now:

    function Check_arrival(time) { //Assuming you are working in 12 hour time, 0 is not a valid var patt = new RegExp("^(0?[1-9]|1[012]):[0-5][0-9]$"); var res = patt.test(time); return res; }

    res=true|false

提交回复
热议问题