By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

Keypress event

P: n/a
Hi,

<input type="text" onkeypress="alert(this.value)">

This doesn't work, it is always 1 character missing because the event
triggers *before* the character is inserted into the text box. How can I
get the entire string, including the last character?
(only needs to work with Mozilla or NN7)

Thanks.

Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
yzzzzz wrote on 13 jul 2003 in comp.lang.javascript:
<input type="text" onkeypress="alert(this.value)">

This doesn't work, it is always 1 character missing because the event
triggers *before* the character is inserted into the text box. How can I
get the entire string, including the last character?
(only needs to work with Mozilla or NN7)


onkeyup= ?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
Scripsit "Evertjan.":
yzzzzz wrote on 13 jul 2003 in comp.lang.javascript:
<input type="text" onkeypress="alert(this.value)">

This doesn't work, it is always 1 character missing because the event
triggers *before* the character is inserted into the text box. How can I
get the entire string, including the last character?
(only needs to work with Mozilla or NN7)


onkeyup= ?


No!!
I think the answer is something like onchange, but that only gets
triggered onblur in Mozilla...
Jul 20 '05 #3

P: n/a
yzzzzz wrote:
Scripsit "Evertjan.":
yzzzzz wrote on 13 jul 2003 in comp.lang.javascript:
<input type="text" onkeypress="alert(this.value)">

This doesn't work, it is always 1 character missing because the event
triggers *before* the character is inserted into the text box. How can I
get the entire string, including the last character?
(only needs to work with Mozilla or NN7)


onkeyup= ?


No!!
I think the answer is something like onchange, but that only gets
triggered onblur in Mozilla...


What do you mean, no?

<form name="myForm">
<input type="text" name="test" onkeyup="alert(this.value);" />
</form>

Tested and alerts the entire content of the input each time a key is released
in IE6SP1, Mozilla 1.5a, Netscape 4.78 and Opera 7.11.

Note that in Mozilla, the backspace key causes a keyup event, but not in IE,
so when the user backspaces in the input, you won't know about the content of
the input until they press another character or tab out (at which point you
could test the content in the onblur event).

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #4

P: n/a
Grant Wagner wrote on 14 jul 2003 in comp.lang.javascript:
yzzzzz wrote:
Scripsit "Evertjan.":
> yzzzzz wrote on 13 jul 2003 in comp.lang.javascript:
>
>><input type="text" onkeypress="alert(this.value)">
>>
>>This doesn't work, it is always 1 character missing because the
>>event triggers *before* the character is inserted into the text
>>box. How can I get the entire string, including the last character?
>>(only needs to work with Mozilla or NN7)
>
> onkeyup= ?


No!!
I think the answer is something like onchange, but that only gets
triggered onblur in Mozilla...


What do you mean, no?

<form name="myForm">
<input type="text" name="test" onkeyup="alert(this.value);" />
</form>

Tested and alerts the entire content of the input each time a key is
released in IE6SP1, Mozilla 1.5a, Netscape 4.78 and Opera 7.11.


Thanks. I usually do not follow up those unsubstanciated "no"s,
for who knows ;-)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.