I'm using this html below:
<input name="t1" class="imgupload" type="file" accept="image/*" capture="camera">
<input type="submit" class="submit" value="Upload">
I'm trying to figure out how to have some alert(); show when the input type="file" is empty
$(document).on('click', '.submit', function(e) {
var check = $(".imgupload").val();
if(check == 'undefined'){
alert();
}
});
Here's an example
http://jsfiddle.net/aesmA/
HTML
<form>
<input type="file" />
<input type="submit" />
</form>
Javascript (jQuery)
$("form").on("submit", function(){
var $file = $(this).find("input[type=file]");
if (!$file.val() || $file.val() == "") {
alert("File is missing");
return false;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With