Web Analytics Made Easy -
StatCounter My form validates correctly, but submits regardless - CodingForum

Announcement

Collapse
No announcement yet.

My form validates correctly, but submits regardless

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • My form validates correctly, but submits regardless


    I built a form for a pet project of mine, and wrote a little JavaScript to validate it and make sure all fields are completed. If they aren't a box pops up and says so. The problem is that the box pops up and the form still submits.


    HEAD:

    <script language="JavaScript">
    function validate()
    {
    if (document.request.name.value == '')
    {
    alert("All fields must be completed!");
    return false;
    }
    if (document.request.location.value == '')
    {
    alert("All fields must be completed!");
    return false;
    }
    if (document.request.computer.value == '')
    {
    alert("All fields must be completed!");
    return false;
    }
    return true;
    }
    </script>


    BODY:

    <form name="request" onSubmit="validate();" action="Action.lasso" method=POST>
    <input type="text" name="name" size="30" value="" maxlength="30">
    <input type="text" name="location" size="30" maxlength="30">
    <input type="text" name="computer" size="30" maxlength="30">
    <input type="submit" value="Submit">
    </form>


    (I've cut out all but what's important.) The form actuall has several other fields, but I can't even get these to work.
    Last edited by bubba_nuts; Jul 13, 2002, 02:08 AM.

  • #2
    Re: My form validates correctly, but submits regardless

    <form name="request" onSubmit="return validate();" action="Action.lasso" method="POST">

    jasonkarldavis.com

    Comment


    • #3
      Grrrrr....

      I knew it was something ridiculously simple.


      Thank you!!

      Comment

      Working...
      X