lundi 8 juin 2020

How to check for empty drop zone in drag and drop jQuery

My website has a form and a button that shouldn't be activated until the form is completed. This is true for all the boxes except for the image dropzone.

How can I verify that the button is inactive unless the dropzone is filled? The 'add' button should only be active when the boxes and image is uploaded.

<div class="container">
  <div class='content'>
    <form action="upload.php" class="dropzone" id="myAwesomeDropzone"></form>  
  </div> 
</div>
$(document).ready(function() {
  $('input[type="text"], textarea').on('keyup', function() {
    var textarea_value = $("#description").val();
    var phone_value = $('input[name="phone"]').val();

    if (textarea_value == '' || phone_value == ''  )
      $('.actions input').attr('disabled', 'disabled');
    else 
      $('.actions input').attr('disabled', false);          
  });
});

Aucun commentaire:

Enregistrer un commentaire