Javascript "value is null or not an object"

Posted on 2006-04-02
Last Modified: 2008-03-04
Hi Experts:  I'm working with some JS I found on this forum (thankyou!)  This is probably a really stupid question, I've been looking at this way to long.  Can someone PLEASE solve the mystery.  "Value is null or not an object" when I try and submit this:

Thank you as usual


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" language="JavaScript">
function countAge(object, birthDay){
     now = new Date();
     bD = birthDay.value.split('/');
            born = new Date(bD[2], bD[1]*1-1, bD[0]);
          years = new Date(now.getTime() - born.getTime());
          base = new Date(0);
          document.all['AGE'].value = years.getFullYear()-base.getFullYear();
function formatdate(datestr)
   var curdate = new Date();
   var curyear = (curdate.getYear()%100)+1980;  // to project 20 years forward and 80 years back (for birthdays, etc)

   datestr = datestr.split("-").join("/").split(".").join("/").split(" ").join("");
   if ( datestr == "" )

   // split the datestr into a 3 part array (mm/dd/yy)
   var mmddyy = datestr.split("/");
   if ( mmddyy.length != 3 )

   // add leading zeros to month and day
   if ( mmddyy[0].length == 1 )
      mmddyy[0] = "0" + mmddyy[0];

   if ( mmddyy[1].length == 1 )
      mmddyy[1] = "0" + mmddyy[1];

   // convert the year to a four digit year
   if ( mmddyy[2].length == 2 )
      //mmddyy[2] = ( parseFloat(mmddyy[2]) > 49 ) ? '19'+mmddyy[2] : '20'+mmddyy[2];

      if ( Math.abs(curyear-parseFloat('19'+mmddyy[2])) <= Math.abs(curyear-parseFloat('20'+mmddyy[2])) )
         mmddyy[2] = '19'+mmddyy[2];
         mmddyy[2] = '20'+mmddyy[2];

   // rebuild the datestr from the formatted array, and check to see if it contains a valid date
   var tmpdate = new Date( datestr=mmddyy.join("/") );
   if ( tmpdate == "NaN" || tmpdate == "Invalid" )

   if ( parseFloat(mmddyy[0]) == tmpdate.getMonth()+1  &&  parseFloat(mmddyy[1]) == tmpdate.getDate()  &&  parseFloat(mmddyy[2]) > 1900  &&  parseFloat(mmddyy[2]) < 2100 )


function checkDate(datewidget)
   var datestr = formatdate(datewidget.value);

   if ( datestr == "NaN" )
      alert("Please enter a valid date for " + );

   datewidget.value = datestr;


function validateForm(theform)
  var rc = checkDate(theform.Birth_Date);


<cfform action="IAapproval_action.cfm" method="POST" onSubmit="return(validateForm(this));"
Name="theForm" enctype="multipart/form-data">
      <td class="label"> Birth Date:</td>
      <td class="label2">
          <input value="" type="text" name="Birth_Date"   maxlength="10" size="8" onChange="validateForm(document.theForm);countAge(this.form, this);" required="yes"  />
        <input value="" type="text" name="AGE" maxlength="3" style="background-color:F5F0E2" size="1" readonly="" />
             <input type="file" name="myFile1">
             <input type="submit" value="Continue" name="btnSubmit">
Question by:whaleyk
    LVL 9

    Accepted Solution

    The point maybe is that you are using a CFFORM tag, that is NOT a HTML FORM tag (maybe a ColdFusion Tag).
    So if you try this code on a simple HTML page, that will not work (theForm.Birth_Date will not reference to your input, but to an eventual attribute of the CFFORM tag).
    Just change the tagname into FORM - dont forget the closing tag ;) - and all will be ok.

    Author Comment

    ha ha... told ya it was stupid :-)  thx, you're right!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now