Javascript -- confused on the return false -- simple validate function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KathyB

    Javascript -- confused on the return false -- simple validate function?

    Hi.

    I have an hmtl page with a function to see if there are any input text
    boxes. If so, that means a user did not complete them (once entered,
    my xsl stylesheet makes them text instead of text input boxes, so
    there should be NO input boxes when the user is clicking the FINISH
    button. However, the FINISH button script still indicates that input
    boxes exist...new to this...return false issue? Is there a better way
    to do this? I also need to send a querystring or form collection for
    (hidden_birth2. aspx?finish=yes ). I couldn't get the script right to
    open the page with querystring from the function, so I ended up doing
    it with this <form> element...proba bly not the best way. Any help
    appreciated! Thanks. Kathy

    function CheckInput()
    {
    var cnAll = document.all;
    for (var i=0;i<cnAll.len gth;i++)
    {
    if(cnAll(i).tag Name=='INPUT')
    {
    alert("You must first complete and SAVE all user inputs!");
    return false; }
    }
    }

    HTML snippet:

    <form action="Hidden_ Birth2.aspx" method="post" onsubmit="retur n
    CheckInput();">
    <input type="Submit" name="finish" value="FINISH">
    <b>Click the FINISH button when work instruction is complete.</b>
    </form>
  • Chris Leonard

    #2
    Re: Javascript -- confused on the return false -- simple validate function?

    >[color=blue]
    > HTML snippet:
    >
    > <form action="Hidden_ Birth2.aspx" method="post" onsubmit="retur n
    > CheckInput();">[/color]

    I think you need the capital S for it to work ......... but I could be wrong

    onSubmit="retur n validate();"


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Javascript -- confused on the return false -- simple validate function?

      "Chris Leonard" <c.leonardNOSPA M@btinternet.co m> writes:
      [color=blue]
      > I think you need the capital S for it to work ......... but I could be wrong
      >
      > onSubmit="retur n validate();"[/color]

      You are wrong.
      In HTML, the case of the letters doesn't matter.
      In XHTML, and in Javascript, the on<event> handlers are written in
      all lower case.

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • asdf asdf

        #4
        Re: Javascript -- confused on the return false -- simple validate function?

        Are you sure your for loop isn't detecting the "input type submit" ?

        Might be worth checking the cnAll(i).type as well.

        Also, I think your event handler might need to return true.

        Hope that helps,
        Ron

        Comment

        • Kathy Burke

          #5
          Re: Javascript -- confused on the return false -- simple validate function?

          Ugh, just realized that I should have other input boxes just not
          type=TEXT boxes...could someone help me with testing for input elements
          where type=TEXT?

          Thanks!

          Kathy

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...