I am trying to validate the time in
00:00 to 11:59 ends with AM OR PM
I was tring some regex,but not getting succesful to validate time. My java script function is
function verifydata( incoming ) {
var re = (1[012]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm);
if(incoming.time.value != '' && !incoming.time.value.match(re))
{
alert("Invalid time format: " + incoming.time.value);
}
}
its not working
I tried this also, not working
var re = /^(?:[01][0-9]|2[0-3]):[0-5][0-9]$/;
let me where I am going wrong?
?ido? (Also, you know(am|pm)will only match lower case letters. Right?) Your regex won't match "00:00" because it only allows "0:00".