6 Replies Latest reply on Mar 24, 2010 5:18 AM by Ned Murphy

    Javascript help please...

    dan hop

      The following code just doesn't work.

      Can't figure out why...

      Please advise.

      Dan H

       

      Version:1.0 StartHTML:0000000105 EndHTML:0000007480 StartFragment:0000002314 EndFragment:0000007444    

      <HEAD>

      <SCRIPT type="text/javascript">

       

      Function ValidateForm(true_false)

       

      {

      if(inputform.name.value== "")

                  {alert("You forgot to enter your name. \n Please do so now.");

                  inputform.name.focus();

                  return false;}

       

      else if(inputform.comment.value== "")

                  {alert("Oops... You forgot to tell us your 'Comments'\n Just place your cursor in the 'Comments' area and tell us your thoughts.");

                  inputform.comment.focus();

                  return false;}

       

      else if(inputform.name.topic== "")

                  {alert("Please enter the SUBJECT of your comments.");

                  inputform.topic.focus();

                  return false;}

       

      else if(inputform.email.value== "")

                  {alert("Please enter your email address so we can reply to your note.");

                  inputform.email.focus();

                  return false;}

       

      else

       

      {return true;}

       

      }

      </SCRIPT>

      </HEAD

      <BODY>

      <FORM name="inputform"

                              id="inputform"

                              method="post"

                              action="formmailer.php" 

                              onSubmit="return ValidateForm(this);" >

      </BODY>

        • 1. Re: Javascript help please...
          Ned Murphy Adobe Community Professional & MVP

          Just eyeballing the js, this line appears to be off...

           

          else if(inputform.name.topic== "")

           

          If this doesn't fix it, if you could post the entire form it would make it easier to troubleshoot.  Both halves of the equation need to be seen

          • 2. Re: Javascript help please...
            dan hop Level 1

            The form is at:

            http://www.hoppernet.info/ynot/talk.php

             

            Thx for replying

            dan h

            • 3. Re: Javascript help please...
              Ned Murphy Adobe Community Professional & MVP

              Did you fix that line to see if it fixed the problem?  I still see it in the page.

               

              One other thing I notice...  "Function" should be "function"

              • 4. Re: Javascript help please...
                Ned Murphy Adobe Community Professional & MVP

                Based on what I see and what I don't see, the following revision of the js code should work...

                 

                <SCRIPT type="text/javascript">

                 

                function ValidateForm(true_false)

                {

                     if (document.inputform.name.value== "")
                     {

                          alert("You forgot to enter your name. \n Please do so now.");
                          document.inputform.name.focus();
                          return false;

                     }

                     else if (document.inputform.comment.value== "")
                     {

                          alert("Oops... You forgot to tell us your 'Comments'\n Just place your cursor in the 'Comments' area and tell us your thoughts.");
                          document.inputform.comment.focus();
                          return false;

                     }

                     else if (document.inputform.topic.value== "")
                     {

                          alert("Please enter the SUBJECT of your comments.");
                          document.inputform.topic.focus();
                          return false;

                     }

                     else if (document.inputform.email.value== "")
                     {

                          alert("Please enter your email address so we can reply to your note.");
                          document.inputform.email.focus();
                          return false;

                     }

                     else

                     {

                          return true;

                     }

                }
                </SCRIPT>

                • 5. Re: Javascript help please...
                  dan hop Level 1

                  Thanks a ton...

                   

                  lower case 'function'

                  'document.' before the 'inputform'

                  removed the extra text from the 'topic'

                   

                  Seems to have done the trick!

                   

                  JavaScript is just SOooooo nit-picky - and indispensable...

                   

                  I have a bit of tidying up to do but I marked this problem as 'solved'.

                   

                  Thanks again Ned.

                   

                  dan H.

                  • 6. Re: Javascript help please...
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome Dan.  Any type of programming is nit-picky.

                    .