473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Press Enter on a text box

JCO
How's come when I press the enter key, I can't get it to execute the correct
password.
It seems that I'm forced to press the button. I want to be able to do both.

How is this done?
Jul 20 '05 #1
7 71906
In article <k0************ *****@nwrddc03. gnilink.net>,
J.********@veri zon.net enlightened us with...
How's come when I press the enter key, I can't get it to execute the correct
password.
It seems that I'm forced to press the button. I want to be able to do both.

You're going to have be a lot more specific.
Got a url?

--
--
~kaeli~
A midget fortune teller who escapes from prison is a small
medium at large.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2
JCO
Sorry for the lack of detail. Site is not hosted at this time.
I will try again. I have a logon form (logon.htm) that contains a Textbox,
Push Button (label = Enter Password) & and a Clear button (label is clear).
Simple as that.

Currently, you would enter the password in the text box and select the
button. The script does the rest. I want to modify it by allowing the user
to type in the password and simply press the enter key as another method to
validate the form. I tried to trap the enter key as shown, but it is not
working.

<FORM NAME="frmPasswo rd" onSubmit="retur n valForm()">
<input type=password name="txtInput" size="15" onkeypress="onE nter();" >
<input type="button" value="Enter Password" name="btnEnter"
onclick="valFor m();">
<input type="reset" value="Clear" name="btnClear" ></p>

function onEnter(){
if(event.keyCod e==13)
document.frmPas sword.btnEnter. click();
}

What is wrong with this?

"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <k0************ *****@nwrddc03. gnilink.net>,
J.********@veri zon.net enlightened us with...
How's come when I press the enter key, I can't get it to execute the correct password.
It seems that I'm forced to press the button. I want to be able to do both.

You're going to have be a lot more specific.
Got a url?

--
--
~kaeli~
A midget fortune teller who escapes from prison is a small
medium at large.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3
On Fri, 13 Feb 2004 02:29:56 GMT, JCO <J.********@ver izon.net> wrote:
<FORM NAME="frmPasswo rd" onSubmit="retur n valForm()">
<input type=password name="txtInput" size="15" onkeypress="onE nter();" >
<input type="button" value="Enter Password" name="btnEnter"
onclick="valFor m();">
<input type="reset" value="Clear" name="btnClear" ></p>

function onEnter(){
if(event.keyCod e==13)
document.frmPas sword.btnEnter. click();
}

What is wrong with this?


You don't cancel the event. Try:

function onEnter( evt, frm ) {
var keyCode = null;

if( evt.which ) {
keyCode = evt.which;
} else if( evt.keyCode ) {
keyCode = evt.keyCode;
}
if( 13 == keyCode ) {
frm.btnEnter.cl ick();
return false;
}
return true;
}
...
<input type="password" name="txtInput" size="15"
onkeypress="ret urn onEnter(event,t his.form);" >

This should work (partially tested on) Opera 7.23, Netscape 7, IE 6, and
Mozilla 1.6. Your original code could only have worked on IE and Opera;
Netscape and Mozilla don't support a global event object, or event.keyCode.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4
JCO
It is working now. Thanks for your help.

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Fri, 13 Feb 2004 02:29:56 GMT, JCO <J.********@ver izon.net> wrote:
<FORM NAME="frmPasswo rd" onSubmit="retur n valForm()">
<input type=password name="txtInput" size="15" onkeypress="onE nter();" >
<input type="button" value="Enter Password" name="btnEnter"
onclick="valFor m();">
<input type="reset" value="Clear" name="btnClear" ></p>

function onEnter(){
if(event.keyCod e==13)
document.frmPas sword.btnEnter. click();
}

What is wrong with this?
You don't cancel the event. Try:

function onEnter( evt, frm ) {
var keyCode = null;

if( evt.which ) {
keyCode = evt.which;
} else if( evt.keyCode ) {
keyCode = evt.keyCode;
}
if( 13 == keyCode ) {
frm.btnEnter.cl ick();
return false;
}
return true;
}
...
<input type="password" name="txtInput" size="15"
onkeypress="ret urn onEnter(event,t his.form);" >

This should work (partially tested on) Opera 7.23, Netscape 7, IE 6, and
Mozilla 1.6. Your original code could only have worked on IE and Opera;
Netscape and Mozilla don't support a global event object, or

event.keyCode.
Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

Jul 20 '05 #5
Ivo
" JCO" <J.********@ver izon.net> wrote in message
news:EE******** **********@nwrd dc01.gnilink.ne t...
<FORM NAME="frmPasswo rd" onSubmit="retur n valForm()">
<input type=password name="txtInput" size="15" onkeypress="onE nter();" >
<input type="button" value="Enter Password" name="btnEnter"
onclick="valFor m();">
<input type="reset" value="Clear" name="btnClear" ></p>

function onEnter(){
if(event.keyCod e==13)
document.frmPas sword.btnEnter. click();
}


I believe I noticed that the "Enter key" functionality depends on the
presence of an <input type="submit"> in the form. I had a form where I
replaced it with a <button> (to allow underlined letters) and the Enter key
stopped working there and then. The non-javascript dependent solution I
ended up with was to add an <input type="submit"> with a height and width of
1.
HTH
Ivo
Jul 20 '05 #6
JCO
Are you saying to change the button (that says "Enter Password") should be
of type submit or are you saying the textbox should be of type submit.

I have changed the textbox to type=password; this makes sense.

"Ivo" <no@thank.you > wrote in message
news:40******** *************** @news.euronet.n l...
" JCO" <J.********@ver izon.net> wrote in message
news:EE******** **********@nwrd dc01.gnilink.ne t...
<FORM NAME="frmPasswo rd" onSubmit="retur n valForm()">
<input type=password name="txtInput" size="15" onkeypress="onE nter();" >
<input type="button" value="Enter Password" name="btnEnter"
onclick="valFor m();">
<input type="reset" value="Clear" name="btnClear" ></p>

function onEnter(){
if(event.keyCod e==13)
document.frmPas sword.btnEnter. click();
}

I believe I noticed that the "Enter key" functionality depends on the
presence of an <input type="submit"> in the form. I had a form where I
replaced it with a <button> (to allow underlined letters) and the Enter

key stopped working there and then. The non-javascript dependent solution I
ended up with was to add an <input type="submit"> with a height and width of 1.
HTH
Ivo

Jul 20 '05 #7
On Fri, 13 Feb 2004 20:47:37 GMT, JCO <J.********@ver izon.net> wrote:

[Fixed top-post]
"Ivo" <no@thank.you > wrote in message
news:40******** *************** @news.euronet.n l...
I believe I noticed that the "Enter key" functionality depends on the
presence of an <input type="submit"> in the form.

[snip]
Are you saying to change the button (that says "Enter Password") should
be of type submit or are you saying the textbox should be of type submit.


What I believe Ivo is trying to say is that when a submit button is
present in a form and the Enter key is pressed whilst a textbox or
password field[1] in the same form has focus, the form should be submitted.

If you change btnEnter to type submit, you might not need the script I
presented (I wasn't really thinking about that, I just fixed your script).

Mike

[1] I don't remember if this extends to other form controls.

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2440
by: Johan Svedberg | last post by:
Hi! I read somewhere that it is impossible to write a program in ANSI-C which only reads one char from the keyboard without having to press Enter (i.e. -questions). Is this true? -- Johan Svedberg, johan@svedberg.pp.se, http://johan.svedberg.pp.se/
5
20711
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number of characters, which are echoed to screen before you have to press enter. For example:- do { /* Begin loop */
3
3486
by: Peder Y | last post by:
Just a quickie: I have a ComboBox, and set it so I can write in its text field. Now, as I write and then press enter, nothing happens (except a beep). Do I need to handle a KeyPress event to invoke the ValueChanged event and make the entered data persistent? It's one of those zoom combo's. - Peder -
2
3581
by: csgraham74 | last post by:
Hello, I wonder if someone could help me. I have an asp.net form which collects data from a piece of XML and displays it on screen. If a piece of data is incorrect i will select the textbox and change the data. If i press enter whilst in the text box it throws an event. My question is how do i disable the event or autopostback of the...
1
7471
by: Mamatha | last post by:
Hi I have a samll application. In that i have one textbox and one button. When i enter some text in text box and press enter then the button will have a focus. How can i do this? Mamatha
11
8626
by: dhirajpriya | last post by:
hi everyone when i create single text box on page and press enter the page refresh how can i stop to refresh the page.... dhiraj
5
1442
by: hmkaddoura | last post by:
Hi All, in my form I have two textboxes (T1,T2) and two buttons (B1,B2) how can i insert text in T1 and press enter to execute B1 event, and insert text in T2 and press enter to execute B2 event. the only thing that i found is that I set in the Form itself the property of AcceptButton and choose which button (only one button) is there...
1
6983
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of...
2
3442
by: donomuch | last post by:
I have a form where user enters a password text, then has to click the Submit Password button. How do I add the option to press Enter key to call the same function 'goForit'? I read similar posts/replies, but I don't know enough to make it work for me. I got this form and script from a free sript site. Trying to learn...thahks in advance for...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.