Discussion Locked

Error in Java Script.SetFocus in IE5?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

1.In my code, a text field with size=3, max size=3, after each letter typed I run a java script to check the lenght of the field. If lenght ==2 (i.e. 3 letters entered), then Set Focus to next field.

2. The above logic worked fine in IE4, and also in Netscape 4.
3. But in IE5, when the 3rd letter is entered, control goes to next field WITHOUT setting the last letter entered. So atmost 2 leters may be entered.
4. Is there any patch available to rectify this? Any work around?

We have used above logic for each field entry in the entire application. The solution thus has to be a highly optimised in terms of effort.
**Our users use both IE4 and IE5 at present.

5 replies

by peter ritchie

Without seeing the code there's not much we can help you with.

Which event are you using? are you returning false false from that event code?

by oddballsixactual

The only answer i can offer you is the one that most developers seem to dread. Write the code so that in the HTML it refers to your function.

On the function, detect if the browser is IE4 or IE5 using the application related attributes in javascript. If it is IE4, use your current code implementation. If it is IE5, then add one to the length that will refocus and continue.

This way, IE 4 will function as it does now. But then IE 5 will look and on length=2 it will not refocus (thus allowing you to enter the third char) but on length=3 it will not allow you to enter any more charachters but will refocus for you. That way you do not exceed the 3 charachters you are looking for and your code will work in both browsers.

This discussion is closed to new replies.