Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is my form clearing?

    So I made a form in html and whenever I type something in my textfields and it shows error messages, after that it refreshes (or resets) and clears all the text I wrote in the text fields.

    But when I type in onsubmit = "return validate()", than it duplicates my error messages but it does not clear my form

    I am guessing my problem is in the html so I will show you it.

    <form id="assignment" name="assignment" method="post" action= "" onsubmit = "return validate()">

    <input type="submit" value="Submit" />

    and on my code the ending goes like this:

    if(message != "")
    {
    alert(message);
    return false;
    }
    else
    {
    return true;
    }
    }

    Thanks alot!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Please provide your complete code.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder Taro's Avatar
    Join Date
    Oct 2011
    Location
    Geraldton, Ontario
    Posts
    155
    Thanks
    1
    Thanked 1 Time in 1 Post
    If you want to reset your form correctly, put this code within the <form></form> tags:

    Code:
    <button type="reset">Reset All</button>
    Last edited by Taro; 02-17-2012 at 02:50 AM. Reason: forgot something
    Element ID

    Webs Support Helper

    Your friendly neighborhood Taroman.


  •  

    Posting Permissions

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