I have to build an HTML Form with an Input text field for Hours and Minutes.
Something like:
Name : [Foo]
Surname
might not be the best but this works for me. i am returning false if there is no error in this case. checks for both format and values.
if (value.substr(2,1) === ':') {
if (!value.match(/^\d\d:\d\d/)) {
return "Invalid Format";
}
else if (parseInt(value.substr(0,2)) >= 24 || parseInt(value.substr(3,2)) >= 60) {
return "Invalid Format";
}
else {
return false;
}
}
else {
return "Invalid Format";
}