I'm doing a website for a running club and I need runners to be able to input their race times as either hh:mm:ss or mm:ss (i.e., no hours required if under an hour). Ideally I'd like to be able to use some kind of mask with the colons, so that if they type in '01' for hours it would automatically input the colon and allow them to start typing the minutes, etc. The minutes and seconds parts of the input need to be constrained to a maximum of 59 in each case (presumably using a regex to filter input).
I kind of assumed there would be loads of examples of such things floating around the input, but I haven't seen any which work smoothly, for example if I start with an existing value of '00:00:00'. Ideally I'd like this as pure Javascript, rather than e.g. with jQuery, but anything which helps me figure out what I need to do is welcome.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…