I have a form that user should select start and end time of an event (only hour and minute). I want to validate the form in such a way that start time of course should be smaller than end time.
For this I have some select elements like this:
<select name="start_timeHour">
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<!-- UP TO 24 -->
</select>
<select name="start_timeMinutes">
.....
<select name="end_timeHour">
.....
<select name="end_timeMinutes">
<!-- I think you got the idea! -->
So I want to get the value of selected options for start and end (hours and minutes and compare them in an if statement). To start the things, I tried to get the value of start_timeHour but the alert function only shows undefined
<script type="text/javascript">
function validateTime()
{
var startHour =
document.forms["add_new_schedule"]["start_timeHour"].value;
alert("Start hour is ".startHour );
}
</script>
Can you tell me what is the problem and how can I manage this?