Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-15-2005, 01:49 AM   PM User | #1
mikeInCali
New to the CF scene

 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mikeInCali is an unknown quantity at this point
enter key doesn't submit the form

This is the code i have in my jsp, but I have to click on the image link to submit the form. The client wants to be able to hit the enter key and login. I'm using struts. Can anyone help, please?

<html:form action="/logon" focus="username" onsubmit="return validateLogonForm(this);">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="5"><spacer type="block" width="1" height="1"></spacer></td>
</tr>
<tr>
<td class="InformationText"><bean:message key="prompt.username"/></td>
</tr>
<tr>
<td><html:text property="username" size="15" maxlength="15"/></td>
</tr>
<tr>
<td height="5"><spacer type="block" width="1" height="1"></spacer></td>
</tr>
<tr>
<td class="InformationText"><bean:message key="prompt.password"/></td>
</tr>
<tr>
<td><htmlassword property="password" size="15" maxlength="25" redisplay="false"/></td>
</tr>
<tr>
<td height="10" nowrap><spacer type="block" width="1" height="1"></spacer></td>
</tr>
<tr>
<td><html:link href="javascript:logonFormBean.submit();"><html:img src="images/g_login_btn.gif" alt="Login" width="46" height="7" border="0" /></html:link></td>
</tr>
</table>
</html:form>
mikeInCali is offline   Reply With Quote
Old 09-15-2005, 12:34 PM   PM User | #2
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
Use a submit button or an input image to submit the form, not a standard link.

Hope this helps

m_n
__________________
"Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
-Tommy Cooper
martin_narg is offline   Reply With Quote
Old 09-15-2005, 01:24 PM   PM User | #3
jbezweb
New Coder

 
Join Date: Feb 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
jbezweb is an unknown quantity at this point
ou could use a <html:button> or Image Button and onclick="document.formname.submit()"

Hope this helps
__________________
Asp.Net 1.1 - 20 hrs
CSS 2.0 - 3 hrs
XHTML 1.1 - 5hrs
JavaScript - 5hrs
Cross-Browser Compatibility - Priceless
jbezweb is offline   Reply With Quote
Old 09-15-2005, 01:39 PM   PM User | #4
rm-f
Regular Coder

 
Join Date: Aug 2005
Location: Toronto, ON, Canada
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
rm-f is an unknown quantity at this point
The answer depends of prog spec. Where the Enter key should triger logon, on entire page, some page part(s) or only in userName/password input fields?
I assume it is the latest:

Code:
function kpHandler(e) {
    var code;
    if(window.event) {
        code = e.keyCode;
    } else {
        code = e.which;
    }
    if(code == 13) { // Enter
        logonFormBean.submit();
    }
}
Code:
<td><html:text property="username" onkeypress="kpHandler(event);" size="15" maxlength="15"/></td>
...
<td><html:password property="password" onkeypress="kpHandler(event);" size="15" maxlength="25" redisplay="false"/></td>
__________________
rm -f /
rm-f is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:38 AM.


Advertisement
Log in to turn off these ads.