[Javascript] "is not defined" error

BRUCE bruce at astound.net
Thu Aug 1 11:12:36 CDT 2002


Hi, I am looking for a little help with a javascript error i am getting on a
form.
What I am trying to do is check to see if a form field is correctly filled
in.
If the field has 0 or 8 characters it is ok, and the form should be
submitted to the cgi.
If it has between 1-7 characters it gets the alert message,
At the moment the alert works, but if the field has 0 or 8 characters I get
a javascript error : "temp is not defned" and the line number referes to the
"    
temp.submit()" line

Below is the coding snippets

In the HEAD sectin I have the following:

   <SCRIPT>
   function checkChars()
{
   if (document.temp.astd.value.length < 8 &&
document.temp.astd.value.length > 0)
    alert("Please contact ASTD for your correct ID number");
   else
    temp.submit()
}
   </SCRIPT>

In the BODY I have a form:
<form method="post"
action="https://w1305.securedweb.net/~redhot/cgi-bin/bnbform.cgi"
name="temp">

the FIELD is set up as:
<input type="text" name="astd" maxlength="8">

and at the SUBMIT button I have the following:
<input type="button" name="submit" value="submit"
onClick="javascript:checkChars()">

Any input would be greatly appreciated,
Thanks,
Bruce




More information about the Javascript mailing list