Solved

enterkey

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lamba in java 8 9 253
countXY challenge 28 171
Can anyone please tell me why i can not find ID  investorCoolGrid inside the jsp page? 1 23
servlet example 17 59
This article was originally published on Monitis Blog, you can check it  here .   Some years back, I worked as the CTO.  During my tenure, I had a head of IT support reporting to me.  He did his job quite well and had a commendable sense of duty…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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