[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

enterkey

Posted on 2004-08-05
3
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 705 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

While there are many new features for iOS 11, these are the five that can improve your digital lifestyle.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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