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

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

P: n/a
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

Jan 17 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Jan 17 '06 #2

P: n/a
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

Jan 17 '06 #3

P: n/a
tlyczko wrote:
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.
--
Rob
Jan 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.