mercredi 19 janvier 2022

how can i include my checkbox in my javascript code to form submit button disable

is there any way to include my form checkbox in my javascript function using "document.getElementById" to enable my submit button when all fields are filled?

My checkbox code:

<input required type="checkbox" id="data" onkeyup="isEmpty()">

My JavaScript code to enable submit button when all fields are filled:

<script>
            function isEmpty(){
                let name = document.getElementById("name").value;
                let lastname = document.getElementById("lastname").value;
                let idnumber = document.getElementById("idnumber").value;
                let pro = document.getElementById("pro").value;
                let course = document.getElementById("course").value;
                let phone = document.getElementById("phone").value;
                let email = document.getElementById("email").value;
                let port = document.getElementById("port").value;
                let uploadresume = document.getElementById("uploadresume").value;
                let left = document.getElementById("left").value;
                let info = document.getElementById("info").value;
                let first = document.getElementById("first").value;
                let second = document.getElementById("second").value;
                let exam1 = document.getElementById("exam1").value;
                let exam2 = document.getElementById("exam2").value;
                let writeup = document.getElementById("writeup").value;

                var check = $('#data');
                var button = $('#apply');

  check.on('change', function() {
    button.prop("disabled", !this.checked);
  }).trigger('change'); 
                
                if (name!="" && lastname!="" && idnumber!="" && pro!="" && course!="" && phone!="" && email!="" && port!="" && uploadresume!="" && left!="" && info!="" && first!="" && second!="" && exam1!="" && exam2!="" && writeup!=""){
                     document.getElementById("apply").removeAttribute("disabled");
                }
            }
        </script>

Thank you!




Aucun commentaire:

Enregistrer un commentaire