Solved

enterkey

Posted on 2004-08-05
3
193 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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