Solved

enterkey

Posted on 2004-08-05
3
191 Views
Last Modified: 2010-04-01
I have a form using Struts and Jstl.  My form on submit calls a struts action that reads the form and
detrmines which button is pressed and then acts accordingly.  This works great but a user pushes the enter key the action is called but
does not know which button was pressed.  Is there a way I can send in the attribute of the button when the enter key is pressed?
the form and button are below.

<ssl:form action="/loginAction.do" onsubmit="return validateLoginForm(document.loginForm)">
<td><img src="img/login_text.gif" border="0" alt=""><img src="img/clear.gif" width="5" height="10" border="0" alt=""></td>
           <td>
              <html:text property="email" value="Email Address"
                 onfocus="clearInputBox(document.loginForm.email, 'Email Address')"
                 maxlength="50" styleClass="blue_border"/>
          </td>
         
         
          <td><html:image property="loginButton" src="img/buttons/header_login_button.gif"
               onmouseover="MM_swapImage('loginButton','','img/buttons/header_login_button_over.gif',1)"
                  onmouseout="MM_swapImgRestore()"
                  alt="Login" border="0"/></td>
        </ssl:form>
0
Comment
Question by:mkowalski68
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 235 total points
ID: 11733827
THis is an IE problem isn't it?  Mozilla does send the button as if it was clicked on, but there seems to be two schools of thought as to whether this is correct...

Everyone except Microsoft says it is...  Microsoft says it isn't ;-)

http://ppewww.ph.gla.ac.uk/~flavell/www/formquestion.html

What I would probably do is, if the form has NONE of the buttons set when the form is submitted, then assume the first one was selected (via the enter key)

You can add this little bit of logic to the validate() method inside the ActionForm :-)

Hope this helps!

Tim
0
 
LVL 9

Expert Comment

by:nimaig
ID: 11733957
Best way is to disable the 'enter' key. Visit the link to see how to disable enter key

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21033013.html#11363894
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11733992
>  Best way

I'd argue that it's the "best" way...  

Pressing return is the accepted standard for submitting forms via the default post method, and disabling it will make your website less accessible to disabled users, etc...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now