Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Firefox y2K issue?

I have a strange difference in behavior between IE and Firefox. I am using some Javascript to process a field entry, and the date calcualtions in Firefox appear to be inccorect. Here is the Javascript function:

function ConfirmInactivate(theDate)
{
   var oDate = document.getElementById(theDate);
   var today = new Date();
   oDate.value = (today.getMonth() + 1) + '/' + today.getDate() + '/' + today.getYear();
   if (document.theForm.Status.value == "I")
   {
      return(confirm("Are you sure you want to Inactivate your account?\n\nThis will mean that you will no longer be active in the RepHunter.net\ndatabase, and that you will not be able to log in to your account?"));
   }
}

This code is triggered via the ONCHANGE attrbitute of a SELECT. A side effect of the function is to change the value of a date field, with the formal parameter "theDate".

In IE, the field is populated with a value such as '5/2/2005'. However, in Firefox, the field is populated with the value '5/2/105', which leads to an SQL Server error when trying to write into a date field.

Can anyone give me the fix for this?
0
jasimon9
Asked:
jasimon9
  • 2
1 Solution
 
GwynforWebCommented:
use  today.getFullYear()


function ConfirmInactivate(theDate)
{
  var oDate = document.getElementById(theDate);
  var today = new Date();
   oDate.value = (today.getMonth() + 1) + '/' + today.getDate() + '/' + today.getFullYear();
  if (document.theForm.Status.value == "I")
  {
     return(confirm("Are you sure you want to Inactivate your account?\n\nThis will mean that you will no longer be active in the RepHunter.net\ndatabase, and that you will not be able to log in to your account?"));
  }
}
0
 
jasimon9Author Commented:
This certainly does the job. Points awarded.
0
 
GwynforWebCommented:
thx for the points
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now