Results 1 to 2 of 2

Thread: Date Calc working in IE not FF

Hybrid View

  1. #1
    Join Date
    Sep 2004

    Date Calc working in IE not FF

    Not a JS guru, so can someone tell me why the following works on a .net aspx page in Javascript for IE, but no FF (v11)? The FF console shows no errors. The alert commented out below shows the correct date in the 1-1-1900 format when entered in the 1/1/1900 format. But, even if I use the 1-1-1900 entry, FF does not calculate age and place in txtAge. IE works great.

    HTML Code:
    getAge = function(form) {
    document.getElementById('txtDOB').value = (document.getElementById('txtDOB').value).replace(new RegExp("/", "g"), "-");
    var now = new Date();
    var DOB = new Date(document.getElementById('txtDOB').value);
    var oneDay = 1000 * 60 * 60 * 24 * 365; //converts from milliseconds
    document.getElementById('txtAge').value = parseInt((now.getTime() - DOB.getTime()) / oneDay);
    <asp:TextBox ID="txtDOB" runat="server" onBlur="javascript:getAge(this.form);"  />

  2. #2
    Join Date
    Nov 2002
    Flint, Michigan, USA
    The returned value of getTime is in the 24-hour range. I think that instead of
    document.getElementById('txtAge').value = parseInt((now.getTime() - DOB.getTime()) / oneDay);
    you probably want
    document.getElementById('txtAge').value = parseInt((now*1 - DOB*1) / oneDay);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center