Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: error in Java Script, Help!!!


Message #1 by "CYNTHIA HALIM" <cynthiahalim@h...> on Mon, 26 Mar 2001 15:18:34 -0000
1)It will be <SCRIPT LANGUAGE = JavaScript> . You have a space between Java and Script
2) You have named your First Name text box as First Name and you are checking the value of txtName object. If you change the name of
the text box (First Name) to txtName, along with the above correction it will work fine.



>From: "CYNTHIA HALIM"
>Reply-To: "javascript"
>To: "javascript"
>Subject: [javascript] error in Java Script, Help!!! 
>Date: Tue, 27 Mar 2001 04:50:15 +0100 
> 
> 
I got some funny bugs on my code, the error always complain on this line:
> 
       <INPUT NAME= txtAge TYPE="text" SIZE =3 MAXLENGTH=3
        onblur="txtAge_onblur()" >
      /** U can find this line somewhere in the bottom **/
> 
please help me out...
than'x
> 
/************************************************************************/
The full code is attached below:       
> 
<HTML>
> 
<HEAD>
<SCRIPT LANGUAGE = Java Script>
> 
function txtAge_onblur()
{
   var txtAge = document.form1.txtAge;
   if (isNaN(txtAge.value) == true)
   {
      alert("Please enter a valid age");
      txtAge.focus();
      txtAge.select();
   }
}
> 
function butCheckForm_onclick()
{
   var myForm = document.form1;
   if (myForm.txtAge.value == "" || myForm.txtName.value == "")
   {
      alert("Please complete all the form");
      if (myForm.txtName.value == "")
      {
         myForm.txtName.focus();
      }
      else
      {
         myForm.txtAge.focus();
      }
   }
   else
   {
      alert("Thanks for completing the form " + myForm.txtName.value);
   }
}
> 
</SCRIPT>
</HEAD>
> 
<BODY>
<FORM NAME=form1 METHOD=POST ACTION ="form1.php" >
<DIV ALIGN = CENTER>
> 
> 
       <LABEL for="first name"> First Name: </LABEL>
       <INPUT NAME ="First Name" TYPE = "Text" id= "first name" size="20">
> 
       <LABEL for="last name"> Last Name : </LABEL>
       <INPUT NAME="Last Name" TYPE ="Text" id="last name" size="32">
> 
       <INPUT NAME= txtAge TYPE="text" SIZE =3 MAXLENGTH=3
        onblur="txtAge_onblur()" >
> 
        <INPUT TYPE="button" VALUE="Check Details" NAME=butCheckForm
       onclick="butCheckForm_onclick()">
> 
</FORM>
> 
</BODY>
</HTML>

  Return to Index