Aloha!
I’ve been borrowing JS for over 7 years to use in an application I developed for work, and still to this day I have no clue what I’m doing. I’m hopeful that a kind JS veteran developer can help me out!
We have a form set up to record periods of days between two dates, and I just want to add JS to verify that the beginning date is not equal to or later than the end date (otherwise the days count would be 0 or negative, which would be nonsensical).
The trick is that the code I thought would work, below, is yielding in IE8 (the ONLY browser my company allows) an error of “Object doesn’t support this property or method”. Here’s the JS code for the date comparison:
[CODE]function dateCompare() {
var EndDate = document.getElementByID(‘End_Date’).value ;
var BeginDate = document.getElementByID(‘Begin_Date’).value ;
alert (‘BeginDate = ‘ + BeginDate + ‘ – EndDate = ‘ + EndDate) ;
return false;
if (EndDate = “”) {
if (EndDate <= BeginDate) {
alert(‘The end date cannot be the same or earlier as the begin date’);
return false;
}
}
}
I tried pulling the field value using document.forms.DateSelector.End_Date.value and if I do that, the code complains that “document.forms.DateSelector.End_Date’ is null or not an object”.
Perhaps, I’m theorizing, the problem is due to the use of the handy dandy calendar picker tool developed by Mihai Bazon and explained here: [url]http://www.dynarch.com/projects/calendar/old/
If anyone has ideas on what I could try to pull the date value from each field and compare the two to verify they are in the right order in time, I’d be very appreciative! I searched and found a huge amount of examples, and tried several, but the issue keeps coming up. I think it’s all about the form field values not pulling up.
Thanks very much in advance for the help!
Me ?