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

earwig75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
replace :
document.getElementById("TheNumber").focus(); 

Open in new window

by :
jQuery("#TheNumber").focus(); 

Open in new window

OR by :
setTimeout(function() {
      jQuery("#TheNumber").focus(); 
, 800);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michel PlungjanIT ExpertCommented:
800 is too slow I would think

It is generally a bad idea to focus on blur as I suspect the asker is
0
leakim971PluritechnicianCommented:
I agree, just a big one to get the right feedback
0
earwig75Author Commented:
Yes this is happening onblur. Is this a bad idea? Will the first solution work?
0
leakim971PluritechnicianCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.