      <div class="modal fade" id="edit-household<?= htmlentities($user_session); ?>">
          <div class="modal-dialog modal-sm">
              <div class="modal-content">
                  <div class="modal-header">
                      <h4 class="modal-title">Manage Household</h4>
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                      </button>
                  </div>
                  <div class="modal-body">
                      <form method="POST">
                          <div id="msg-householdedit"></div>
                          <div class="form-group">
                              <label>HouseHold#:</label>
                              <input type="text" class="form-control" id="edit_householdno" alt="household_no2" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" >
                               <label id="msg-householdno2" style="color:#CC0000;" ></label>
                          </div>
                          <div class="form-group">
                              <label>Purok#:</label>
                                 <select type="text" class="form-control" id="edit_purokno" alt="purok_no2" autocomplete="off">
                                    <option selected disabled value="">&larr; Select Purok No. &rarr;</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                          </div>
                          <div class="form-group">
                              <label>Total Members of the Family:</label>
                              <input type="text" class="form-control" id="edit_totalmembersofthefamily" alt="total_membersofthefamily2" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" >
                          </div>
                  </div>
                  <div class="modal-footer justify-content-between">
                      <input type="hidden" id="edit_householdid">
                      <input type="hidden" alt="user_edit" id="user_edit" value="<?= htmlentities($user_session); ?>">
                      <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                      <button type="button" class="btn btn-primary" id="edit-househ">Update</button>
                  </div>
                  </form>
              </div>
          </div>
      </div>
      <script>
          document.addEventListener('DOMContentLoaded', () => {
              let btn = document.querySelector('#edit-househ');
              btn.addEventListener('click', () => {

                  const household_no = document.querySelector('input[alt=household_no2]').value;
                  const purok_no = $('#edit_purokno option:selected').val();
                  const total_membersofthefamily = document.querySelector('input[alt=total_membersofthefamily2]').value;
                  const household_id = document.querySelector('input[id=edit_householdid]').value;
                  const user = document.querySelector('input[alt=user_edit]').value;

                  var data = new FormData(this.form);

                  data.append('household_no', household_no);
                  data.append('purok_no', purok_no);
                  data.append('total_membersofthefamily', total_membersofthefamily);
                  data.append('household_id', household_id);
                  data.append('user', user);

                      $.ajax({
                          url: '../../controllers/edit_household.php',
                          type: "POST",
                          data: data,
                          processData: false,
                          contentType: false,

                          async: false,
                          cache: false,

                          success: function(data) {
                              $('#msg-householdedit').html(data);

                          },
                          error: function(data) {
                              console.log("Failed");
                          }
                      });
                //  }

              });
          });
      </script>

          <script type="text/javascript">
    $(document).ready(function() {
 
        var timeOut = null; // this used for hold few seconds to made ajax request
 
        var loading_html03 = '<img src="../../images/ajax-loader.gif" style="height: 20px; width: 20px;"/>'; // just an loading image or we can put any texts here
 
        //when button is clicked
        $('#edit_householdno').keyup(function(e){
 
            // when press the following key we need not to make any ajax request, you can customize it with your own way
            switch(e.keyCode)
            {
                //case 8:   //backspace
                case 9:     //tab
                case 13:    //enter
                case 16:    //shift
                case 17:    //ctrl
                case 18:    //alt
                case 19:    //pause/break
                case 20:    //caps lock
                case 27:    //escape
                case 33:    //page up
                case 34:    //page down
                case 35:    //end
                case 36:    //home
                case 37:    //left arrow
                case 38:    //up arrow
                case 39:    //right arrow
                case 40:    //down arrow
                case 45:    //insert
                //case 46:  //delete
                    return;
            }
            if (timeOut != null)
                clearTimeout(timeOut);
            timeOut = setTimeout(is_available03, 500);  // delay delay ajax request for 1000 milliseconds
            $('#msg-username').html(loading_html03); // adding the loading text or image
        });
  });
function is_available03(){
    //get the username
    var household_no = $('#edit_householdno').val();
 
    //make the ajax request to check is username available or not
    $.post("check_householdno.php", { household_no: household_no },
    function(result)
    {
        console.log(result);
        if(result != 0)
        {
            $('#msg-householdno2').html('Household No. already exists');
            document.getElementById("edit-househ").disabled = true;
        }
        else
        {
            $('#msg-householdno2').html('<span style="color:#006600;">Available</span>');
            document.getElementById("edit-househ").disabled = false;
        }
    });
 
}
</script>