bootstrap radio buttons with custom text-field - unable to type inside text-field<button> vs. <input type=“button” />. Which to use?How can I know which radio button is selected via jQuery?Put text input inside label for radio button?How to select a radio button by default?Bootstrap - Text-align class for inside tableResetting Twitter Bootstrap form radio button group. How?Knockout + Bootstrap 3 Radio ButtonsCannot display HTML stringRadio button group loose value except radio with input fieldBootstrap disabling radio btn-group with data-toggle=buttons

Fixing obscure 8080 emulator bug?

Non-aqueous eyes?

Fermat's statement about the ancients: How serious was he?

Warning about needing "authorization" when booking ticket

CSV how to trim values to 2 places in multiple columns using UNIX

Why was this person allowed to become Grand Maester?

A map of non-pathological topology?

What ways have you found to get edits from non-LaTeX users?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Extreme flexible working hours: how to get to know people and activities?

Are polynomials with the same roots identical?

What is the color of artificial intelligence?

Thread Pool C++ Implementation

How to ensure color fidelity of the same file on two computers?

Teaching a class likely meant to inflate the GPA of student athletes

Meaning of 'lose their grip on the groins of their followers'

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

Does the Long March-11 increase its thrust after clearing the launch tower?

Wooden cooking layout

English word for "product of tinkering"

What to do when surprise and a high initiative roll conflict with the narrative?

Why can my keyboard only digest 6 keypresses at a time?

Which languages would be most useful in Europe at the end of the 19th century?

Is using 'echo' to display attacker-controlled data on the terminal dangerous?



bootstrap radio buttons with custom text-field - unable to type inside text-field


<button> vs. <input type=“button” />. Which to use?How can I know which radio button is selected via jQuery?Put text input inside label for radio button?How to select a radio button by default?Bootstrap - Text-align class for inside tableResetting Twitter Bootstrap form radio button group. How?Knockout + Bootstrap 3 Radio ButtonsCannot display HTML stringRadio button group loose value except radio with input fieldBootstrap disabling radio btn-group with data-toggle=buttons






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to add a custom text input to a group of radio buttons. I want the user to be able to write a custom text inside the text-field. While the text-field shows up correctly, I am unable to type inside the text-field. Any idea on how to fix this?



I am using bootstrap and this is my code:



<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Active
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option2" autocomplete="off"> Radio
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option3" autocomplete="off"> Radio
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
</label>

</div>


My fiddle:
http://jsfiddle.net/nLxgdhaf/










share|improve this question




























    1















    I am trying to add a custom text input to a group of radio buttons. I want the user to be able to write a custom text inside the text-field. While the text-field shows up correctly, I am unable to type inside the text-field. Any idea on how to fix this?



    I am using bootstrap and this is my code:



    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


    <div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-secondary active">
    <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
    </label>
    <label class="btn btn-secondary">
    <input type="radio" name="options" id="option2" autocomplete="off"> Radio
    </label>
    <label class="btn btn-secondary">
    <input type="radio" name="options" id="option3" autocomplete="off"> Radio
    </label>
    <label class="btn btn-secondary">
    <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
    </label>

    </div>


    My fiddle:
    http://jsfiddle.net/nLxgdhaf/










    share|improve this question
























      1












      1








      1








      I am trying to add a custom text input to a group of radio buttons. I want the user to be able to write a custom text inside the text-field. While the text-field shows up correctly, I am unable to type inside the text-field. Any idea on how to fix this?



      I am using bootstrap and this is my code:



      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


      <div class="btn-group btn-group-toggle" data-toggle="buttons">
      <label class="btn btn-secondary active">
      <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option2" autocomplete="off"> Radio
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option3" autocomplete="off"> Radio
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
      </label>

      </div>


      My fiddle:
      http://jsfiddle.net/nLxgdhaf/










      share|improve this question














      I am trying to add a custom text input to a group of radio buttons. I want the user to be able to write a custom text inside the text-field. While the text-field shows up correctly, I am unable to type inside the text-field. Any idea on how to fix this?



      I am using bootstrap and this is my code:



      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


      <div class="btn-group btn-group-toggle" data-toggle="buttons">
      <label class="btn btn-secondary active">
      <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option2" autocomplete="off"> Radio
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option3" autocomplete="off"> Radio
      </label>
      <label class="btn btn-secondary">
      <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
      </label>

      </div>


      My fiddle:
      http://jsfiddle.net/nLxgdhaf/







      html twitter-bootstrap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 18:57









      AaronDTAaronDT

      1,0522928




      1,0522928






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem is that selecting the input triggers bootstrap's radio button selection, which overrides your textbox selection. A quick hacky solution would be to disable the bootstrap functionality via e.preventDefault() and e.stopPropogation(), focus on the textbox, and then select the radio button via js. Here's a working example:






          document.querySelector('input[name="other"]').addEventListener('click', function (e) 
          e.preventDefault();
          e.stopPropagation();

          /* console.log(this.previousElementSibling.checked) */

          this.previousElementSibling.checked = true

          document.querySelectorAll('label').forEach(function (el)
          el.classList.remove('active')
          el.classList.remove('focus')
          )

          this.parentElement.classList.add('active')
          )

          <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

          <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
          <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


          <div class="btn-group btn-group-toggle" data-toggle="buttons">
          <label class="btn btn-secondary active">
          <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
          </label>
          <label class="btn btn-secondary">
          <input type="radio" name="options" id="option2" autocomplete="off"> Radio
          </label>
          <label class="btn btn-secondary">
          <input type="radio" name="options" id="option3" autocomplete="off"> Radio
          </label>
          <label class="btn btn-secondary">
          <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
          </label>

          </div>








          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55327374%2fbootstrap-radio-buttons-with-custom-text-field-unable-to-type-inside-text-fiel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The problem is that selecting the input triggers bootstrap's radio button selection, which overrides your textbox selection. A quick hacky solution would be to disable the bootstrap functionality via e.preventDefault() and e.stopPropogation(), focus on the textbox, and then select the radio button via js. Here's a working example:






            document.querySelector('input[name="other"]').addEventListener('click', function (e) 
            e.preventDefault();
            e.stopPropagation();

            /* console.log(this.previousElementSibling.checked) */

            this.previousElementSibling.checked = true

            document.querySelectorAll('label').forEach(function (el)
            el.classList.remove('active')
            el.classList.remove('focus')
            )

            this.parentElement.classList.add('active')
            )

            <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

            <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


            <div class="btn-group btn-group-toggle" data-toggle="buttons">
            <label class="btn btn-secondary active">
            <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
            </label>
            <label class="btn btn-secondary">
            <input type="radio" name="options" id="option2" autocomplete="off"> Radio
            </label>
            <label class="btn btn-secondary">
            <input type="radio" name="options" id="option3" autocomplete="off"> Radio
            </label>
            <label class="btn btn-secondary">
            <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
            </label>

            </div>








            share|improve this answer



























              0














              The problem is that selecting the input triggers bootstrap's radio button selection, which overrides your textbox selection. A quick hacky solution would be to disable the bootstrap functionality via e.preventDefault() and e.stopPropogation(), focus on the textbox, and then select the radio button via js. Here's a working example:






              document.querySelector('input[name="other"]').addEventListener('click', function (e) 
              e.preventDefault();
              e.stopPropagation();

              /* console.log(this.previousElementSibling.checked) */

              this.previousElementSibling.checked = true

              document.querySelectorAll('label').forEach(function (el)
              el.classList.remove('active')
              el.classList.remove('focus')
              )

              this.parentElement.classList.add('active')
              )

              <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

              <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
              <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
              <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


              <div class="btn-group btn-group-toggle" data-toggle="buttons">
              <label class="btn btn-secondary active">
              <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
              </label>
              <label class="btn btn-secondary">
              <input type="radio" name="options" id="option2" autocomplete="off"> Radio
              </label>
              <label class="btn btn-secondary">
              <input type="radio" name="options" id="option3" autocomplete="off"> Radio
              </label>
              <label class="btn btn-secondary">
              <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
              </label>

              </div>








              share|improve this answer

























                0












                0








                0







                The problem is that selecting the input triggers bootstrap's radio button selection, which overrides your textbox selection. A quick hacky solution would be to disable the bootstrap functionality via e.preventDefault() and e.stopPropogation(), focus on the textbox, and then select the radio button via js. Here's a working example:






                document.querySelector('input[name="other"]').addEventListener('click', function (e) 
                e.preventDefault();
                e.stopPropagation();

                /* console.log(this.previousElementSibling.checked) */

                this.previousElementSibling.checked = true

                document.querySelectorAll('label').forEach(function (el)
                el.classList.remove('active')
                el.classList.remove('focus')
                )

                this.parentElement.classList.add('active')
                )

                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

                <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
                <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


                <div class="btn-group btn-group-toggle" data-toggle="buttons">
                <label class="btn btn-secondary active">
                <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option2" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option3" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
                </label>

                </div>








                share|improve this answer













                The problem is that selecting the input triggers bootstrap's radio button selection, which overrides your textbox selection. A quick hacky solution would be to disable the bootstrap functionality via e.preventDefault() and e.stopPropogation(), focus on the textbox, and then select the radio button via js. Here's a working example:






                document.querySelector('input[name="other"]').addEventListener('click', function (e) 
                e.preventDefault();
                e.stopPropagation();

                /* console.log(this.previousElementSibling.checked) */

                this.previousElementSibling.checked = true

                document.querySelectorAll('label').forEach(function (el)
                el.classList.remove('active')
                el.classList.remove('focus')
                )

                this.parentElement.classList.add('active')
                )

                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

                <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
                <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


                <div class="btn-group btn-group-toggle" data-toggle="buttons">
                <label class="btn btn-secondary active">
                <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option2" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option3" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
                </label>

                </div>








                document.querySelector('input[name="other"]').addEventListener('click', function (e) 
                e.preventDefault();
                e.stopPropagation();

                /* console.log(this.previousElementSibling.checked) */

                this.previousElementSibling.checked = true

                document.querySelectorAll('label').forEach(function (el)
                el.classList.remove('active')
                el.classList.remove('focus')
                )

                this.parentElement.classList.add('active')
                )

                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

                <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
                <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


                <div class="btn-group btn-group-toggle" data-toggle="buttons">
                <label class="btn btn-secondary active">
                <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option2" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option3" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
                </label>

                </div>





                document.querySelector('input[name="other"]').addEventListener('click', function (e) 
                e.preventDefault();
                e.stopPropagation();

                /* console.log(this.previousElementSibling.checked) */

                this.previousElementSibling.checked = true

                document.querySelectorAll('label').forEach(function (el)
                el.classList.remove('active')
                el.classList.remove('focus')
                )

                this.parentElement.classList.add('active')
                )

                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

                <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
                <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


                <div class="btn-group btn-group-toggle" data-toggle="buttons">
                <label class="btn btn-secondary active">
                <input type="radio" name="options" id="option1" autocomplete="off" checked> Active
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option2" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option3" autocomplete="off"> Radio
                </label>
                <label class="btn btn-secondary">
                <input type="radio" name="options" id="option4" autocomplete="off"> Other <input type="text" name="other">
                </label>

                </div>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 19:30









                HybridHybrid

                3,95321032




                3,95321032





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55327374%2fbootstrap-radio-buttons-with-custom-text-field-unable-to-type-inside-text-fiel%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript