我可以问一下,如果在combox中使用javascript验证时间是否包含选项,它可以验证她/他是否选择了已经过去的时间
<input type="time" id="time" name="timeval">
答案 0 :(得分:1)
如果你有时间用HH:MM:SS(24小时)格式,你可以像下面那样做
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");
获取当前时间
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);