I have a form with a file input and I want to check if it is empty when the form is submitted.
I have this code:
$('form#new_comment').submit(function(e) {
var $this = $(this);
var $input = $this.find('input').val();
if($($input == '')) {
alert ("you must choose a image");
return false;
e.preventDefault();
}
});
But it always says you must choose a image, even when I have chosen an image.
Where is the problem?