Link to home
Start Free TrialLog in
Avatar of earwig75
earwig75

asked on

focus not working in Firefox

I am using the following jquery/function to bring the focus back into a text box if the proper number isn't returned. It works fine in IE but in Firefox the "focus" doesn't work. It allows the user to move to the next field after displaying the error. Can someone assist?

function CheckTheNum(ID) {
    var cfcAsAjax = new jsobj();
    x = cfcAsAjax.CheckTheNum(ID);
    if (x == true) {
        //    document.getElementById('labelNum').innerHTML = '<span>Number:</span>';
        jQuery("#labelNum").html("<span>Number:</span>");
    } else {
        jQuery("#labelNum").html("<span>The Number:</span><br /><span class='red'><strong>Please enter a valid number</strong></span>");
        if (ID != "") {
            document.getElementById("TheNumber").focus();
        }
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
800 is too slow I would think

It is generally a bad idea to focus on blur as I suspect the asker is
I agree, just a big one to get the right feedback
Avatar of earwig75
earwig75

ASKER

Yes this is happening onblur. Is this a bad idea? Will the first solution work?
you're just asking if the jQuery team do the right job...
https://api.jquery.com/focus/

now in some contex (maybe in your context) it may not work