Javascript "value is null or not an object"

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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('/');
     if(bD.length==3){
            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 == "" )
   {
      return(datestr);
   }

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

   // 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];
      }
      else
      {
         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" )
   {
      return("NaN");
   }

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

   return("NaN");
}


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

   if ( datestr == "NaN" )
   {
      datewidget.select();
      alert("Please enter a valid date for " + datewidget.name );
      datewidget.focus();
      return(false);
   }

   datewidget.value = datestr;

   return(true);
}


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

  return(rc);
}
</script>
</head>

<body>
<cfform action="IAapproval_action.cfm" method="POST" onSubmit="return(validateForm(this));"
Name="theForm" enctype="multipart/form-data">
      <table>
         <tr>
      <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"  />
         Age:
        <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">
      </td>
    </tr>
      </table>
</cfform>
</body>
</html>
whaleykAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smaccariCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whaleykAuthor Commented:
ha ha... told ya it was stupid :-)  thx, you're right!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.