How do I prevent this.focus(); from going to the next table row??

T

tlyczko

I have this code in a form input box contained in the 4th column cell
of a 4-column table:

onblur = "if (testExp(this.value, 'message') == false) {window.focus();
this.focus();}"

testExp checks the input box form value, but every time it is false
(wrong kind of value), the focus goes to the form input box in the 1st
column of the *next* table row.

The "wrong" kind of value gets placed into the input box, then the
cursor goes to the first column in the next table row.

How do I prevent this?? Happens with either IE or FF, it only needs to
work properly in IE though.

Thank you,
Tom
 
R

Randy Webb

tlyczko said the following on 1/17/2006 1:33 PM:
I have this code in a form input box contained in the 4th column cell
of a 4-column table:

onblur = "if (testExp(this.value, 'message') == false) {window.focus();
this.focus();}"

have testExp set the focus.

Don't use onblur, use onchange, to validate fields.

function testExp(fieldRef,message){
...........

fieldRef.focus();
}

If you don't set focus, then the next field in Tab Order will gain focus.
 
T

tlyczko

Thank you, Randy...

I finally got it working after your suggestion, although the best I can
do so far is to return the focus to where it belongs.

Hopefully tonight I can figure out how to shade the text box if it has
the wrong type data in it...

Thank you, Tom
 
R

RobG

tlyczko said:
Thank you, Randy...

I finally got it working after your suggestion, although the best I can
do so far is to return the focus to where it belongs.

Hopefully tonight I can figure out how to shade the text box if it has
the wrong type data in it...

You can attempt that with CSS by modifying the input's style object
where supported, but not all browsers will obey.
 

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
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top