I’m trying to write a form that will disable at a certain time and I want that to happen using javascript. However, since people can easily change the date on their computer, I was hoping to use the date provided by Apache as the comparison date. I tried some simple stuff but the SSI echoed date would not compare against the javascript date. My code is below. Any ideas?
var currenttime = '<!--#config timefmt="%a %b %d %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->'
var currenttime = currenttime+' GMT-0400 (EDT)';
var disableDate = new Date();
disableDate.setFullYear(2011,9,18);
disableDate.setHours(17,0,0,0);
if(disableDate < currenttime)
$('#date_field').attr("disabled", true);
You are comparing a string to a date. Convert your
currenttimestring into a Date object first:That said, try instead to use conditional SSI to utterly disable the form server-side instead of getting JavaScript to do it for you.