JavaScript help

Results 1 to 4 of 4

Thread: JavaScript help

  1. #1
    Join Date
    Dec 1969
    Posts
    10

    Default JavaScript help

    Below is a sample of my code. I am trying to write a script where an alert box pops up and the user is returned to the form if the UserName field is not filled in. I looked at your examples but can&#039t quite understand it or make it work with my form. Can you help me fill in the blanks? Thank you.<BR><BR>&#060;script language="JavaScript"><BR>&#060;!--<BR>function VerifyData()<BR>{<BR>If ????????<BR>{<BR> alert ("You must enter a user name");<BR> Return False;<BR>}<BR>Else<BR> Return True;<BR>}<BR>--><BR>&#060;/script><BR>.....<BR>&#060;form action="RequestAdd.asp" name="Info" method="POST" onSubmit="return VerifyData()"><BR>&#060;input type="text" name="UserName" size="20"><BR>.....<BR>

  2. #2
    Gary Rainbow Guest

    Default RE: JavaScript help

    JavaScript is sensitive about case. "Return False" and "Return True" must be all lower case. Also, the "If" and "Else" must be lower case.

  3. #3
    Join Date
    Dec 1969
    Posts
    10

    Default RE: JavaScript help

    Thanks for the info. I still need help with my If statement. Should this work? I get an error message when I try to run this.<BR><BR>if (isEmpty(Document.Info.UserName.Value))<BR><BR>Tha nks again.

  4. #4
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: JavaScript help

    &#060;script language="JavaScript"><BR>&#060;!--<BR>function VerifyData()<BR>{<BR>if (????) // if statement must have parthensis around it<BR>{<BR>alert ("You must enter a user name");<BR>return false; // need to be lower case<BR>}<BR>else // lower-case<BR>return true; // lower-case<BR>}<BR>// --><BR>// You need to comment the -->, else Netscape will barf<BR>&#060;/script><BR>.....<BR>


Posting Permissions

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