LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Javascript: Successive calls to focus() fail (https://www.linuxquestions.org/questions/programming-9/javascript-successive-calls-to-focus-fail-585832/)

eantoranz 09-19-2007 10:35 AM

Javascript: Successive calls to focus() fail
 
I have a long page with a number of fields which I have to "validate". In the validation process I want to be able to tell the user about each "failed" field with an alert and have the focus on the field.

It's something like:

Code:

for (;;) {
    field = getField();

    if (field.value is incorrect) {
        field.focus();
        alert("This field is wrong");
    }
}

The alerts do show up one after the other, but only the first focus() repositions the user's view. All the others don't reposition the user's view.

I tried adding a blur() after each alert to "force" unfocusing the field, but that didn't help. Any ideas why this is happening? I'm testing with FF2. I just tested on IE and it works the way I want it to. How could I get it doen on FF?


All times are GMT -5. The time now is 05:57 AM.