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 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to catch the enter key in a single input field form

    Hello,

    I've got a very simple form like:

    <fieldset><legend>Search on name</legend>
    <table class=body >
    <form name="search" action="search.php" method="POST" >
    <input type="hidden" name="action" value='name'>
    <tr>
    <td width=170 valign=center>Name</td>
    <td width=480 valign=center>
    <input size="20" maxlength="30" type="text" name="search_name" value="" ></td>
    </tr>
    <tr>
    <td width=170 valign=center><input type="Submit" name="submit" value="Send"></td>
    <td width=480 valign=center>&nbsp;</td>
    </tr>
    </form>
    </table>
    </fieldset>

    I would like the enter key to work (Submit). If you fill out this form the enter key does not work. I have tried scripts that check for the enter key to be pressed. They work fine with me in textarea fields. But until now they do not work in a normal input field.

    Does anyone know how to handle this I've tested it with ie6 on XP and ie5.x on Win98.

    I only have this problem when I have a single field form. If i have a form with two input fields the enter key does generate a submit (as wanted).
    Last edited by NL_Fred; 07-05-2004 at 02:18 PM.
    Fred

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    they should always work in normal text fields.

    go to Google and see for yourself. type something - anything - into the search field and hit enter, and it'll submit the form. see!

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One of the tricks I use to test what a form is passing is to use Google by changing the form action to google and the method to get. Google then prints out a nice little line of everything passed.

    IE: The requested URL /?action=name&search_name=dddd was not found on this server.

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Willy Duitt
    One of the tricks I use to test what a form is passing is to use Google by changing the form action to google and the method to get.
    that's a neat trick. never thot of doing that before.

    thanx for sharing the tip, m8.

  • #5
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sure I know what should work, but what if it does not!!!!

    If I have just one input field and no other fields in the form but just the submit, the enter does not work. If I have an other field in this form the enter does work!!! Strange?

    B.t.w. Google also has a radiobutton field!!
    Last edited by NL_Fred; 07-05-2004 at 04:05 PM.
    Fred

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just ran your codes and they work but in order for the enter key to work properly, there must be a submit button within the form also......

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by NL_Fred
    Sure I know what should work, but what if it does not!!!!

    If I have just one input field and no other fields in the form but just the submit, the enter does not work. If I have an other field in this form the enter does work!!! Strange?
    yes, indeed. Google works even if there's nothing typed into it's single field.

    curious.

  • #8
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do I do wrong then. I have a submit button in my code
    Fred

  • #9
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by NL_Fred
    Hello,
    <input type="Submit" name="submit" value="Send"></td>
    should be:
    Code:
    <input type="submit" name="submit" value="Send"></td>

  • #10
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    also,

    Code:
    <input type="hidden" name="action" value='name'>
    might be better as:
    Code:
    <input type="hidden" name="my_action" value='name'>

  • #11
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I updated the "Submit" to "submit", but.... as expected that didn't change a bit. The submit button already worked so "Submit" was interpreted okay.

    It has to be something else.
    Fred


  •  

    Posting Permissions

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