Created
August 1, 2011 11:06
-
-
Save adamjforster/1117940 to your computer and use it in GitHub Desktop.
Tests if a string is a valid time for a 24hr clock.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_valid_time(value) { | |
/* Validates that a string is a valid time in either of the following | |
* formats: | |
* | |
* HH:MM | |
* HH:MM:SS | |
*/ | |
regex = /^([01]\d|2[0-3])(:[0-5]\d){1,2}$/; | |
return regex.test(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment