TEXT OnChange

B

Bob Bedford

I'd like to fire a JS function from the Onchange event of a Text edit.
Unfortunately it doesn't fire when I hit any key, but only when leaving the
control. I've tried with OnKeyup, and it works, but it isn't compatible with
NS6.

Please any advice ?

Best regards.

Bob
 
K

kaeli

bedford1 said:
I'd like to fire a JS function from the Onchange event of a Text edit.
Unfortunately it doesn't fire when I hit any key, but only when leaving the
control. I've tried with OnKeyup, and it works, but it isn't compatible with
NS6.

No, onchange doesn't fire unless focus leaves the element.

Try onkeypress, depending on what you're trying to accomplish. Sometimes it's
a fine substitute, sometimes it isn't.

--
--
~kaeli~
The man who fell into an upholstery machine is fully
recovered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
B

Bob Bedford

OnKeyPress is the same than OnKeyUp, it doesn't work with NS6
I will add an additional window.

Thanks

Bob
 
B

Ben Measures

Andrew said:
Advise users? If some web-site author
'advised' me to get a decent browser
I'd advise them to get a working site

All an author can do to help interoperability is to code to the w3.org
standards and add workarounds for broken browsers. In the case of onkey*
there is no workaround - if a browser doesn't support it no workaround
can be written to emulate it.

So all the OP can do now is use this attribute (as specified in the
w3.org standards) and advise users to use a standards-compliant browser.
Since there are no workarounds he is fully justified in doing this.

If even the features of the specifications given by w3.org are taboo
then what hope is there for the progression of the www?
 
R

Richard Cornford

Andrew said:
Advise users? If some web-site author
'advised' me to get a decent browser
I'd advise them to get a working site
(assuming imparting that advice was quicker
than the 'back' button, which, since it's
not, leave's the site in the lurch).

Who cares? ( I mean, ..besides the site author. )

With no code presented to demonstrate that there even is a problem with
Netscape 6, rather than an authoring mistake, it would be premature to
be bothering the user about their choice of browser.

Richard.
 
B

Ben Measures

kaeli said:
I thought NN6 was fully html 4.01 compliant.
I learn something new daily.

AOL/Netscape prematurely released NN6. It was based on pre-1.0 Mozilla
(iirc it was based on M18, pre-0.6). Inevitably there were bugs,
incompatibilities and general brokeness. It should never have happened.

It was only when NN7 was released (based on post-1.0 Mozilla code) that
it became anywhere near the standards-compliant browser that it is today.
 
G

Grant Wagner

onkeypress should work with Netscape 6. I am almost certain I used it
successfully. However, if you are trying to add it programmatically:

document.forms['myForm'].elements['myElement'].onkeypress = myHandler;

Then you need the following code in your <form>

<input type="text" name="myElement" value="" onkeypress="">

The empty onkeypress="" is _not_ optional in some early versions of Gecko-based
browsers if you are trying to add an event handler programmatically. These
early versions of Gecko-based browsers had a problem where if event handlers
were not registered when the HTML was parsed, your event would be attached
_after_ the standard application-level event handler.

The following code snippet should work just fine in Netscape 6 (I tested it in
Mozilla 1.0 and it generated the correct alert() on each keypress):

<body onload="
document.forms['myForm'].elements['myElement'].onkeypress =
function (e) {
alert('You pressed ' + (e && e.which ? e.which : event.keyCode));
}
">
<form name="myForm">
<input type="text" name="myElement" value="" onkeypress="">
</form>
</body>
 
M

Michael Winter

I'd like to fire a JS function from the Onchange event of a Text edit.
Unfortunately it doesn't fire when I hit any key, but only when leaving
the control.

That's exactly what it's supposed to do. If the value of a control changes
between entering and exiting the control, a change event is fired.
I've tried with OnKeyup, and it works, but it isn't compatible with NS6.

Please any advice ?

Validate using the change event. If you're trying to stop certain
characters being entered, it won't be reliable. Someone could paste a
value in and you won't catch the prohibited characters.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,101
Members
48,773
Latest member
Kaybee

Latest Threads

Top