Hey all i need to find a way to check to see if the user clicked on a date thats in the future (ie. a date thats pass todays date) Code: onClick="if(self.gfPop)gfPop.fPopCalendar(document.frmSurvey.dc);return false;" Code (markup): The date is formatted like 04/14/2006 If today was the 14 and the user tryed to click any date after the 14th then i need it to blank out the frmSurvey.dc text box and tell them they can not select that date... or if thats hard then simply clear the text box. Thanks for your help, David
Not sure if this is the best way to do it, but I'd do something like IF currentyear < selectedyear or if currentyear == selectedyear and currentmonth < selectedmonth or if currentyear == selectedyear and currentmonth == selectedmonth and currentday < selectedday THEN clear the textbox Code (markup): So, in javascript, it might look something like this var datestring = "04/27/2008"; var d = new Date(); var cd = [d.getMonth() + 1, d.getDate(), d.getFullYear()]; // current date var sd = datestring.split('/'); // selected date if ( cd[2] < sd[2] || cd[2] == sd[2] && cd[0] < sd[0] || cd[2] == sd[2] && cd[0] == sd[0] && cd[1] < sd[1] ) document.frm.dc.value = ""; Code (markup):
a. the code you are working with is copyrighted b. the code you gave me relies on code you didn't give me c. i don't get the sense that you are putting in much an effort to solve this yourself. I'm new here, so I don't mean to be presumptuous, but I'm guessing you will have better luck at a site like rentacoder.com. Dex
In case you will have issues with JavaScript Date here are some useful functions: http://dotnetcaffe.blogspot.com
An easier way is to just create a date object from the string and compare the dates: var datestring = "12/06/2009"; var now = new Date(); datestring = new Date(datestring); if(datestring>now) { //do whatever now } Code (markup): Just for reference anyway