I would like to understand how by a check js to confirm Butão

Asked

Viewed 26 times

0

`

Confirmations
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse">
                                    <i class="fas fa-minus"></i>
                                </button>
                            </div>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" requerid="">
                                        <label class="form-check-label" for="flexCheckDefault">confirmaaquitbm.
                                        </label>
                                    </div>

                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
                                        <label class="form-check-label" for="flexCheckDefault">confirma aqui
                                        </label>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
Register `

someone can help me by placing a js to enable the register when confirming the conditions ?

  • has many similar questions on the site do a search, for example https://answall.com/q/438018/57220

1 answer

0

You can use jquery and leave it as follows

                       <div class="card-tools">
                                <button type="button" id="button" class="btn btn-tool" disabled="True" data-card-widget="collapse">
                                    <i class="fas fa-minus">Confirma</i>
                                </button>
                            </div>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault1" requerid="">
                                        <label class="form-check-label" for="flexCheckDefault">confirmaaquitbm.
                                        </label>
                                    </div>

                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault2">
                                        <label class="form-check-label" for="flexCheckDefault">confirma aqui
                                        </label>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
  //Detecta alterações nos check box 
  $(document).on('change', '.form-check-input', function() {
  //Pegando valor dos Checks
  var elemento1 = document.getElementById('flexCheckDefault1').checked;
  var elemento2 = document.getElementById('flexCheckDefault2').checked;

  if(elemento1 & elemento2) {
     document.getElementById('button').disabled = false;
  }else{
     document.getElementById('button').disabled = true;
  }   
   });

</script>

  • 1

    thank you helped me a lot the system now ta perfect for me <3 and a user registration giving two rules to those who register for a php system that I did with Laravel

Browser other questions tagged

You are not signed in. Login or sign up in order to post.