Link to home
Start Free TrialLog in
Avatar of mkowalski68
mkowalski68

asked on

enterkey

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>
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Best way is to disable the 'enter' key. Visit the link to see how to disable enter key

https://www.experts-exchange.com/questions/21033013/Disable-Enter-key-for-Both-Netscape-4-and-IE-6.html#11363894
>  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...