JavaScript - Time Validation function
Here is a handy function for validating time.
function fn_ValidateTime(){
var strCDA_X_Field = document.getElementById('strCDA_X_Field');
var strValue = strCDA_X_Field.value;
var aryTemp = [];
var blValid = true;
//if the time is 8 digits 00:00:00
if(strValue.length == 8){
//if there is a seim-colon at 2 and 5
if((strValue.indexOf(':') == 2) && (strValue.indexOf(':') == 5)){
aryTemp = strValue.split(':');
//Check each element to see if they are correct, hours can be up 99 but the rest must be less than or equal 59
if(aryTemp[0] <= 99){
if(aryTemp[1] <= 59){
if(aryTemp[2] <= 59){
blValid = true;
}
else{
blValid = false;
}
}
else{
blValid = false;
}
}
else{
blValid = false;
}
}
else{
blValid = false;
}
}
else{
blValid = false;
}
return blValid;
}