How to disable file input if text field is used
I need to disable a file input if a certain text input is used. However,
if the end user changes their mind, then I want to be able to enable the
file input if the text input is empty.
This works well to disable the file input if the text input is used.
However, if I clear the text input, the file input remains disabled:
$("#linkurl").on('keyup blur', function(){
$('#link').attr('disabled', this.value.trim().length);
});
I tried this, but it obviously didn't work:
$("#linkurl").on('keyup blur', function(){
if($.trim($("#linkurl").val()) === ''){
$('#link').attr('disabled');
}else{$('#link').removeAttr('disabled');}
});
I'm open to suggestions if there's a better way...
Thanks...
No comments:
Post a Comment