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

  • Home
  • SEARCH
  • 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 616507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:20:04+00:00 2026-05-13T18:20:04+00:00

Recently I’m maintaining a legacy project. I found one javascript dead loop problem in

  • 0

Recently I’m maintaining a legacy project. I found one javascript dead loop problem in a page. The demo code is as follows. When the user clicks the first inputbox and type in 3 then directly click the second input box, the dead loop occurs. Now my question is what’s the best way to solve or prevent this kind of problem? Great thanks.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>

<input type="text" name="a" id="a" value="" />
<input type="text" name="b" id="b" value="" />

<script type="text/javascript" charset="utf-8">
var a = document.getElementById("a");
a.onblur = function(){
    if(a.value.length === 1){
        alert("aaa");
        a.focus();
        a.select();
        return false;
    }
}

var b = document.getElementById("b");
b.onblur = function(){
    if(b.value < a.value){
        alert("bbb");
        b.focus();
        b.select();
        return false;
    }
}
</script>
</body>
</html>
  • 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-13T18:20:04+00:00Added an answer on May 13, 2026 at 6:20 pm

    This works in IE.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-type" />
    </head>
    
    <body>
        <input id="a" name="a" type="text" value="" />
        <input id="b" name="b" type="text" value="" />
    
        <script charset="utf-8" type="text/javascript">
    var bInBlurA = false;
    var a = document.getElementById("a");
    a.onblur = function(){
        if (bInBlurB) return;
        if(a.value.length === 1){
            bInBlurA = true;
            alert("aaa2");
            a.focus();
            a.select();
        }
    }
    
    var bInBlurB = false;
    var b = document.getElementById("b");
    b.onblur = function(){
        if (bInBlurA) return;
        if(b.value < a.value){
            bInBlurB = true;
            alert("bbb2");
            b.focus();
            b.select();
        }
    }
    a.onfocus  = function()
    {
        bInBlurA = false;
    }
    b.onfocus = function()
    {
        bInBlurB = false;
    }
        </script>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently downloaded some code for a minor open-source project related to a small webgame
recently, while reading former's code in my current project, I encounter the problems below:
Recently, I found that an array can be initialize as follows: private static int[]
Recently I found some simple source code of a bootloader.The following is the simple
Recently one of our app servers went down, when it was rebooted the Python
Recently I've found how to add a link to an item in Visual Studio
Recently the PHP manual started showing the following warning on every mysql function page:
recently, while working on a db2 -> oracle migration project, we came across this
Recently I've begun to code in Objective-C for iOS 5 devices. My brand new
Recently we have released our product. Our team decided to preserve the source code

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.