Closed Bug 202639 Opened 22 years ago Closed 22 years ago

Date field blank; date picker defaults to year 2103

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: mark.richards, Assigned: rogerl)

References

()

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401 I just installed Mozilla and attempted some testing. Included in the test was a web page I am developing which is a front end for presenting solar water heating data in graphical form. Two fields in the form are used for a date picker (javascript). In both fields, the date should default to the current day, however the fields appear blank. When the date picker is activated by clicking in the field, the correct month and day appears but the year selected is 2103. Reproducible: Always Steps to Reproduce: 1.Load page 2.Click mouse in start date field 3. Actual Results: Calendar appears with year 2103. Expected Results: Date should appear in start and end date fields when page loads and should default to today. Calendar should appear when field clicked showing current year, month and day. Since this is under development, the page data should not be made public.
Have to mark this one invalid; sorry. The problem is shown below: function GetDateString() { var d, s = ""; d = new Date(); etc. etc. s += (d.getYear() ) + "-"; <<<----------- getYear() has been deprecated etc. etc. return(s); } The getYear() method has been deprecated from the ECMA standard for JavaScript; use getFullYear() instead. See these references: bug 22964 bug 45764 bug 100123
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
The above explains why you're getting the wrong year. What about the failure of the date fields to initialize on load? Notice that when you load your page in Mozilla, you get an error in Tools > Web Development > JavaScript Console: Error: mainform is not defined Source File: http://www.massmicro.com/solarone.php Line: 165 That comes from the block of code trying to initialize the date field: <script language='javascript'> var d = GetDateString(); mainform.d1.value = d ; </script> Note you have not declared |mainform| anywhere in JavaScript. How is the <script> supposed to recognize it? That's the mistake. You defined it as an HTML form-name: <form name='mainform' etc. etc. > The proper way to reference this from JavaScript is via the document object of the DOM (Document Object Model): document.mainform.d1.value = d ; Note IE has proprietary behavior that puts every HTML name automatically into the JavaScript namespace, which covers up the issue. But standard references on the DOM will mention the correct syntax, and that is what should be used -
Status: RESOLVED → VERIFIED
Removing confidential flag from bugs resolved INVALID
Group: security
You need to log in before you can comment on or make changes to this bug.