-2

Can i ask if how to validate time using javascript in combox contain having a choices and it can validate if she/he choose the time that already past

<input type="time" id="time" name="timeval">

1 Answers1

1

if you have time in HH:MM:SS (24 hr)format than you can do like as below

var str1 = "10:20:45",
    str2 = "05:10:10";

if (str1 > str2)
    alert("Time 1 is later than time 2");
else
    alert("Time 2 is later than time 1");

get current time as below

var d = new Date();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();

var curr_sec = d.getSeconds();

document.write(curr_hour + ":" + curr_min + ":" 
+ curr_sec);
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263