Yeah I've run in to this also. The problem is that the onBlur event for the
input fires after the onChange method. So while the focus is being set in
the onChange event, the onBlur event is called next and the input loses its
focus.
You may want to try to kill the event chain by setting the event.returnValue
to false or and this is what I do, is give up on the onChange event and
implement the same code in the onBlur event. Yeah you may incur slight
overhead because now you are processing the input field every time you tab
off the control rather than only when the value changes, but if you need to
you can always code this functionality easily in the onBlur handler method
with a simple "if" statement.
Regards
Mike
"ra" <r@yahoo.com> wrote in message news:3f**********@corp.newsgroups.com...
Hi
I can't figure this out - I have a routine that is triggered after a text
field is changed and if an error it displays an alert message and should
put focus back to the field in error but focus or select won't seem to work -
the cursor just stays in the next field.
Im using IE6.0
The code is like
<script>
CheckNumeric(num){
// Some error checking code
if (error)
{num.focus();
num.select();}}
</script>
// some more html...
<input name="t1" type="text" size="5"
onchange='javascript:CheckNumeric(this)'>
/// and so forth...
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----