Hello all,
When a person selects a value from the dropdown list and hits submit. the form should be validated before sending to next page.
The selected hour should not be greater than or less than the current hour. In other words if the current time is 4:32 then he should select 4:00 not 3:00 or 5:00.
please help
this is what I wrote so far..
The code I have written is not working some how.. Please help many thanks in advance
nubee
When a person selects a value from the dropdown list and hits submit. the form should be validated before sending to next page.
The selected hour should not be greater than or less than the current hour. In other words if the current time is 4:32 then he should select 4:00 not 3:00 or 5:00.
Code:
<select name="hr" id="select2">
<option value="01:00">01:00</option>
<option value="02:00">02:00</option>
<option value="03:00">03:00</option>
<option value="04:00">04:00</option>
....
.....
<option value="22:00">22:00</option>
<option value="23:00">23:00</option>
<option value="00:00">00:00</option>
</select>
<input type="submit" name="Submit" value="Click Here To Submit" ONCLICK="CheckTime()">
this is what I wrote so far..
Code:
<SCRIPT LANGUAGE="JavaScript">
function CheckTime() {
var selected_value = this.form.hr.value;
var currentTime = new Date()
var hours = currentTime.getHours()
var strTime = hours +":00" +" "
if(strTime>selected_value) {
alert("Please select correct time");
return false;
}
return true;
}
</SCRIPT>
nubee