View Full Version : onSpaceDown

05-27-2006, 12:41 PM
I use this function to move to the next field when a SPACE is pressed.

netscape = "";
ver = navigator.appVersion;
len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");
function spaceMover(t) {
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k==32) {

The problem is I can't "cut" the space from the field because it's added AFTER the function.
Is there a way to prevent it from adding the space in the first place?


05-27-2006, 05:01 PM
space seem a strange choise, uparrow for a text input?

05-27-2006, 06:51 PM
it's a first name field
and a last name field afterwards.

some people press the space button and start writing their last name before they notice that there is a seperate field for this.

05-27-2006, 07:13 PM
not trying to be difficult but wont



05-27-2006, 07:32 PM
As I already said before, I can't manipulate with the lastName field because the space is added AFTER the function is over.

no matter what i'll do WITHIN the function, the space will be added afterwards.

I'm looking for a way to PREVENT the space from being added.

05-27-2006, 07:38 PM
what key event are you using..

i woud suggest onkeyup.

05-27-2006, 07:51 PM
yeah, but it's not so simple.

when a user types really fast, sometimes the key is up only after he type another 2-3 keys.

so it will cause even bigger problem:
if my name is Shmil Shmilonsky and i type really fast, the name will show:
[Shmil Sh] [milonsky]

any idea how to use the onkeydown and prevent space from being shown?
or maybe another solution using onkeyup?


05-27-2006, 08:05 PM
Ok, i got it, i even tested with SendKeys, no one is typing that fast. And it's really quite simple. Use onkeydown. and right after you focus on the lastname field, put:

return false

and that should take care of it.

05-27-2006, 08:09 PM
field because the space is added AFTER the function is over


05-27-2006, 08:17 PM
on blur wouldn't work because keyevent is still processing. which is why you still get a few chars after you focus the other field. if you return false, then the event is halted, freeing up the process for the focus to occur before the next event is triggered

05-30-2006, 07:14 PM
good idea.
it's working partially:
after space is pressed - no key is entered within the first field and i'm being passed successfuly to the second field BUT the space is still shown (at the beginning of the second field).

I can't explain it. don't know why and how to solve it.

06-03-2006, 10:26 AM
please help.
it has to have a solution :\

anyother idea?