SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need <enter> to submit on a non-submit button

    Hey all.

    I have an <input text> field which is used for searching inventory. When the user enters text and clicks enter, the search is executed.

    If the user enters text and presses <enter>, the search is executed by trapping the keyboard event.

    When the user enters text and the automcomplete has "suggestions" that drop-down, if the user selects the text from the drop-down and hits enter, all is well. If, when the suggestions are in the drop-down, the user presses <enter> without actually arrowing down/selecting one of the suggestions, the page is "submitted". Because it is submitted, there is information that is not being carried over so the page "chokes". The search string as well as login info is not carried over. I can put the login info into a hidden field, but the search string is blanked out so it won't be picked up.

    When the search button is clicked, a javascript function is called which retrieves the data from the DB. Same code is executed when <enter> is pressed.

    How would I go about stopping the <enter> key from acting as a submit button? I'm trapping for keyboard event 13 and calling a JS function, but the page is still submitted.

    Any ideas?

    ...

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I use "automcomplete="off", pressing <enter> acts a submit.


Bookmarks

Posting Permissions

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