SitePoint Sponsor

User Tag List

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

    Enter to submit, potentially many forms in one page

    The root cause of this problem is that our designers want to use CSS styled "buttons" instead of standard form buttons. So one of the other developers made a button class that he put on an anchor, and then some JS fires to submit the form. Of course, the trouble is that the enter key won't submit the form.

    I tried putting a standard submit button in the form, and then hiding it with CSS, and that works fine in all browsers except IE.

    I figured out how to listen for the enter key and then submit the form, but what happens when we have multiple forms on one page? We have a simple login form on every page, and if that is the only form on the page we are fine. But many of our pages have their own forms as well, so if I submit on enter in the login, that form will fire if the user hit's enter for a different form in the page.

    I was going down the route of writing code that will insert a function into every form element on the page to identify the currently focused form in the onfocus, but that seems like overkill. Is there a simpler way to skin this cat?

  2. #2
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I found an answer, but I still need to do more testing to make sure.

    If I use <input type="image"...> instead of the anchor tags with CSS, it seems to work. But then we'll have to make images of their CSS "buttons", but that should be a lot better than all this cludgy JS stuff I've been trying.


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
  •