Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 /


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •