Hi my problem right now is how to disable a submit button until the select dropdown and input field is filled in. My disable is working but it won't enable even though i have already selected in the dropdown and in the input field. Here is my code. Hope you could help me.
echo "<form action='portal-files/user-file-upload.php' method='post' enctype='multipart/form-data'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='100000' />";
echo "<input type='hidden' name='admin_id' value='$user->id' />";
echo "<select name='id' id='form-option' class='test-only'>";
echo '<option selected="selected">' .'Choose a User'. '</option>';
foreach ($registeredUsers as $key => $value) {
$registered = JFactory::getUser($value);
echo '<option value="'.$registered->id.'">'.$registered->name.'</option>';
}
echo "</select>";
echo "<input name='uploadedfile' type='file' id='custom-file-input' class='test-only'/> <br/>";
echo '<input type="submit" name="submit" value="Upload" id="custom-submit-input" disabled="disabled">';
echo "</form>";
<script>
jQuery(document).ready(function() {
jQuery('.test-only').on('keyup change', function(){
if (jQuery('#form-option').val() == '') {
jQuery('#custom-submit-input').prop('disabled', true);
} else {
jQuery('#custom-submit-input').prop('disabled', false);
}
});
});
});
</script>