Issue with "return false;"

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

    #1

    Issue with "return false;"

    I have a return false as part of my if statement and my form is still submitting.

    Here is the simple example. Any suggestions?
    if(msg != ""){
    alert(msg);
    return false;
    }else{
    //submit the form
    }
  • Andrew Thompson

    #2
    Re: Issue with "return false;"

    On 26 May 2004 12:10:08 -0700, gachris wrote:
    [color=blue]
    > Here is the simple example.[/color]

    It's probably in the bit you left out..
    URL?
    [color=blue]
    >..Any suggestions?[/color]

    Supply an URL,
    get regular sleep,
    be good to your mother.
    (not necessarily in that order) ;-)

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology

    Comment

    • Lee

      #3
      Re: Issue with "return false;"

      gachris said:[color=blue]
      >
      >I have a return false as part of my if statement and my form is still
      >submitting.
      >
      >Here is the simple example. Any suggestions?
      >if(msg != ""){
      > alert(msg);
      > return false;
      >}else{
      > //submit the form
      >}[/color]

      Most commonly this is because your validation function is returning
      false to the onsubmit handler, but the onsubmit handler function
      is not returning that value to the browser. The onsubmit handler
      is the value of the HTML onsubmit attribute (usually), so instead
      of something like:

      onsubmit="myVal idationFunction (this)"

      you should have something like:

      onsubmit="retur n myValidationFun ction(this)"

      Comment

      Working...