I used the following code to check for the Enter key being pressed while in
a form field.  There may be a better way to write it, but the code below
works for me.  It first checks the browser version (because the code to
check for a keystroke is different between browsers). The function, which is
called from a form field checks the keystroke.

var isNav, isIE
if (parseInt(navigator.appVersion) >= 4) {
        if (navigator.appName == "Netscape"){
                isNav = true
        } else {
                isIE = true
        }
}

function checkEnter(evt){
        var theKey
        if (isNav) {
                theKey = evt.which
        } else {
                theKey = window.event.keyCode
        }
        if (theKey == "13") {
                document.frmLogin.submit()
        }
}

Sample form field:
<input type="password" name="Password" size="10" maxlength="20"
onkeypress="checkEnter(event)">

Bob

-----Original Message-----
From: Milks, Jim [mailto:[EMAIL PROTECTED]]
Sent: January 12, 2001 10:21 AM
To: CF-Talk
Subject: OT: Forms, Submit and maybe JavaScript


Hi All,
I have a basic login form with 3 textboxes, and the suits and design guys
replaced my submit and reset buttons with images. Now, users must tab to the
"Submit" image and hit enter, as opposed to hitting enter from one of the
textboxes after supplying the required info. My HREF from the submit image
calls a JavaScript function which makes sure the textboxes have appropriate
values in them and then submits if all is ok.

How can I allow the users to submit without tabing to the Submit image?

Thanks

James
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to