lundi 7 août 2017

disable button with two condition

l have a problem with jquery to disable the button that depends on two conditions.the first condition that the user must select one option.the second condition that the user must upload a file.I try to write the code for the first condition but does not work well

here is the code for the form to upload a file

<form action="" method="post" enctype="multipart/form-data">

     

    <input id="file-id"type="file" name="file1" ></input>

this is the code for a button that I want to disable it if the two condition invalid

<button  class="enableOnInput"type="submit" value="Submit" id="submitorder" disabled="disabled">send file</button>

and this is the code for the list that enables user to select one option

    <select id="select-id" name="select-name" >
    <option value="" selected="selected" ></option>
   <option value="cr">Course Report. </option>
    <option value="st" >Students' Sample of Test (Final Exam).(Highest)</option>
</select>

here is the javascript code to disable the send file button for the first condition only.

<script type="text/javascript"src="http://ift.tt/wV40hO"></script>
<script type="text/javascript" >
$(function(){
  $('#select-id').keyup(function(){
  if($(this).val() == ''){
$('.enableOnInput').prop('disabled',true);
    }else{
      $('.enableOnInput').prop('disabled', false);
    }
  });
});
</script>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire