Results 1 to 4 of 4

Thread: Form with only one input field!

  1. #1
    Join Date
    Jul 2010

    Form with only one input field!


    I have made a variety of forms, but I just made one with only one input field type="text". The mysterious case is that when I press enter, the page reloads and places the values in the url!!

    Why does it do that, and how do I prevent it???

    If I make one more text field it doesn't happens!!

    HTML Code:
    <form name="testform">
    	<input type="text" name="testinput">
    (The form action is not defined because I use ajax to handle the form)

  2. #2
    Join Date
    Nov 2010
    Los Angeles, CA
    What are you trying to do with your form? It needs a method and action attribute to know what to do when it is submitted. Since you haven't provided either, it is using the GET method and the default action is to reload the page. That's why you're seeing this behavior.

  3. #3
    Join Date
    Jul 2010
    Hi Big O

    Thanks for the reply!

    I use JavaScript to handle the form with a onchange action. That's why I haven't placed a action inside the form tag!

    I understand that it by default uses GET method, and that it reloads the page, but why doesn't it happen if there are more then one text field?

  4. #4
    Join Date
    Jul 2010
    Well the quick solution is to place this inside the <form> tag:

    onsubmit="return false"

    Maybe not pretty but it works!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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