Enable next input field when not empty
Hello,
I am looking for some help with the following function.
I have disabled a file input field which has a textbox above it. I am trying to make it so that when there is text in the textbox the file field is enabled and disabled when it is emtpy.
I do not want to assign id's to the file inputs so im trying to use the current jQuery selector.
- $('.disable').click(function(event){
- var $this = $(this);
- var file = $this.closest('input[type=file]');
- if($(this).val() === ""){
- $($file).attr('disabled', true);
- } else {
- $($file).removeAttr('disabled');
- }
- event.stopPropagation();
- });
However I am receiving a $file is undefined error?
Thanks.