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 8950687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:29:48+00:00 2026-06-15T13:29:48+00:00

So every ‘special-input’ div contains an input field. I am trying regulate when each

  • 0

So every ‘special-input’ div contains an input field. I am trying regulate when each information can be entered into each input field.

Initially, I would like the first input field from the top to be enabled, while the rest of the input fields below it be disabled.

OnChange of input field 1, I would like for the next input field below it to be enabled, while the rest disabled. OnChange of input field 2, I would like for input field 3 to become enabled, while the rest remain disabled, etc…

I know I can use JQuery’s attr() to enable input fields when needed, but I am unsure how to apply the logic to accomplish this as JQuery is quite new to me.

<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
<div class="special-input"><input type="text" /></div>
...... 
...... 
......
<div class="special-input"><input type="text" /></div>
  • 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-06-15T13:29:49+00:00Added an answer on June 15, 2026 at 1:29 pm
        // Cache the inputs, this is a good way to improve performance of your 
        // jQuery code when re-using selectors.
            var $inputs = $('.special-input :input');
        // Disable all except the first input
            $inputs.not(':first').attr('disabled', 'disabled');
            $inputs.each(function(i) {
        // For each input, bind a change event to enable the next input, 
        // if the user presses enter, the next textbox will receive focus. if the user
        // presses tab, the following input won't receive focus, so you'll have to add 
        // code if you want this to work.
                $(this).on('change', function() {
                    // Get the index of the current input element we're looking at,
                    // We need to re-wrap the $input[i] element as it is now a normal 
                    // DOM element.
                    var $nextInput = $($inputs[i + 1]);
                    $nextInput.removeAttr('disabled').focus();
                });
            });​
    

    Edit: You can see a working example at http://jsfiddle.net/dFZEq/11/

    Edit 2:

    To enable the next line’s set of elements after a certain condition is met, use this:

    var $specialInputs = $('.special-input');
    
    // don't disable the first line's input elements.
    $specialInputs.not(':first').find(':input').attr('disabled', 'disabled');
    
    $specialInputs.on('change', function() {
        var $this = $(this);
    
        if ($this.find(':input').filter(function() {
            // you can change this filter to match any condition you 
            // like, for now we'll just make sure all inputs have a non-empty value
            return $(this).val() == '';
        }).length == 0) {
    
            var $nextInputSet = $($specialInputs[$this.index() + 1]).find(':input');
    
            // enable the next set of elements
            $nextInputSet.removeAttr('disabled');
    
            // focus your element here, requires more work
            $nextInputSet.first().focus();
        }
    });​
    

    Example at http://jsfiddle.net/tFG5W/

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

Sidebar

Related Questions

Every application contains some settings that are configurable. These settings can more or less
Every time when I'm trying to load the .dll in my application, I'm getting
Every thing goes in code, but not saving data in SQLite db. Can any
Every time I pull code into my repository after making changes to JS or
Every time I try to import a project downloaded from googlecode into Eclipse but
Every time I test my program, I have to input a bunch of the
Every example I can find either goes through creating a table without a gui
Every method I write to encode a string in Java using 3DES can't be
Every time my forms loads/open it will prompt System.Data.DataRowView, How can I possibly remove
Every example I find of anyone implementing plugins in android seems to use aexp.intent.action.

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.