I have a form with 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 he always says you must choose a image
, even when I selected the image.
Where is the problem?
source share