ドロップダウンボックスから選択した2つの時間値があります。時間形式はhh:mm am/pm
です。2つの日付を比較する必要があります。私はこのコードを実行しましたが、うまくいきません。
<select id="eventstarttime">
<option>10:00am</option>
........
<option>3:00pm</option>
</select>
<select id="eventstoptime" onblur="return checktime()">
<option>10:00am</option>
........
<option>3:00pm</option>
</select>
javascriptメソッドは
function checktime()
{
var start = document.getElementById("eventstarttime").value;
var end = document.getElementById("eventstoptime").value;
if(Date.parse('01/01/2011 '+end) < Date.parse('01/01/2011 '+start))
{
alert("End time should exceed the start time");
}
else if(Date.parse('01/01/2011 '+end) -Date.parse('01/01/2011 '+start)==0)
{
alert("Start time and end time cannot be same");
}
return false;
}