05-15-2007, 05:13 PM
A HTML Form has 2 sets of 3 dropdown select lists. The 1st set is for users to enter the start time & the 2nd set is for users to enter the end time. The 1st dropdown select list in both the sets is where users will select hours, the 2nd dropdown select list in both the sets is where users will select minutes (the 2nd dropdown select list in both the sets have 4 options - 00, 15, 30 & 45). The 3rd dropdown select list in both the sets is where users will select either AM or PM.
Now it's quite obvious that the start time can come after the end time (on the same date). For e.g. you can't let users select the start time as 9:00 AM & the end time as 6:00 AM.
How do I validate that the end time always comes after the start time & vice-versa?
05-15-2007, 07:15 PM
OK...friends...I got the solution but am facing a small problem. his is how I did it :
var dtDate=new Date()
var starttime=new Date(iDate,iMonth,iYear,sHour,sMinute,sSeconds);
var endtime=new Date(iDate,iMonth,iYear,eHour,eMinute,eSeconds);
alert("END TIME CANNOT COME BEFORE START TIME!")
alert("END TIME CANNOT BE THE SAME AS START TIME!")
}The above code works fine but have a look at the else if line. If both the start time & end time are, say, 7:45 AM, then the else if condition doesn't get executed & the alert message doesn't pop up!
Any idea what could be the reason behind that?
05-16-2007, 01:51 AM
The Date constructor syntax is:
new Date(yr_num, mo_num, day_num [, hr_num, min_num, sec_num, ms_num])
What you used is:
new Date(day_num, mo_num, yr_num [, hr_num, min_num, sec_num, ms_num])