Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:06:23+00:00 2026-05-27T05:06:23+00:00

I am focusing back textbox if it does not have required values. Textbox is

  • 0

I am focusing back textbox if it does not have required values. Textbox is not focusing back after execution of this function. However it is alerting (alert("Must be 1");) correctly.

$("#textbox").blur(function(event){
       if ($(this).text != "1"){
          event.preventDefault();
          alert("Must be 1");
          $(this).focus(); 
        }
});

Any idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:06:24+00:00Added an answer on May 27, 2026 at 5:06 am

    You could do this:

    $("#textbox").blur(function(event){
           var tb = this;
           if ($(this).val() != "1"){
              event.preventDefault();
              alert("Must be 1");
              setTimeout( function() { $(tb).focus(); }, 1);
            }
    });
    

    By putting the “.focus()” call in a timeout, you make the switch happen in a separate event loop. Note also that you were trying to get the value incorrectly (“.text”), and also that I have to preserve the reference to the element in “tb”.

    I suspect that this might not work in Safari. Safari is really reluctant to obey “.focus()” calls, and it gets confused by “alert()”. Of course, if you deliver the message to the user by some other means (and please do so :-), then it might work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After the ajax function is over. in success messages I'm focusing to the specific
While similiar questions have been asked, this one's focused on which is best/easiest to
I am not sure which strategy to adopt...I am focusing on my operation getting
Bit confused with this one. Basically, I have a column in a table, and
Focusing on clients who can not afford PCI compliant servers I intend to limit
I have a problem in focusing the listview.In my form i have a listview
I am learning this trade and is currently focusing on NSDictionary. I am currently
The code I have here is preliminary. I am focusing on the clipping procedures.
I have a UIDatePickerView inside UIActionSheet as a input to the UITextField. When focusing
Focusing in this question: php-json-highcharts-load-database-result The answer was to do the follow each :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.