on my page ... How do I...">Geek Answers HandbookHow to check input type = "file" file or not using jquery?I have a file upload control <input id="File1" type="file" />on my page ... How do I check for an input type = "file" file or not using jquery with a click of a button upload?+5jquery validation input-type-fileChendur pandian Apr 15 '10 at 5:37source share3 answersif (jQuery('#File1').val()) { /* There are files */ } +16Quentin Apr 15 '10 at 5:45source shareInstead of jQuery, use "required". Only one attribute will check the input = file file or not. Example:<input type="file" required/> +11Hardik sondagar Jan 18 '13 at 5:25source share$('#upload').bind('click', function(e){ if( $('#File1').val() != ""){ // file selected } else{ // no file selected } }); +4jAndy Apr 15 '10 at 5:46source shareMore articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1043940/add-foreign-key-constraints-to-existing-tables-in-ruby-on-rails-mysql&usg=ALkJrhhnC9QNuNR3ak1H-p64HU57ul7zLQThrowing C ++ exception after inline-asm - c ++ transitionhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1043942/examples-of-good-jpa-java-desktop-application&usg=ALkJrhgy2wPfYn_hXuzo23Ag41pVf5x-IAwhich is safer - data transfer using socket programming OR SSH / SCP / FTP - sshDisplay rows from MySQL where datetime is in the next hour - mysqlhow to call a method in a thread using aruguments and return some value - multithreadingJQuery: Calling a Checkbox Click event with jQuery - jqueryHow to access an XML file in a maven project so that it remains available when packaging - javaHow do you get an asp.net attribute attribute with auto-generated? - asp.netHow to extract geographic data from an open street map or Google maps - language-agnosticAll Articles
I have a file upload control <input id="File1" type="file" />on my page ... How do I check for an input type = "file" file or not using jquery with a click of a button upload?
<input id="File1" type="file" />
upload
if (jQuery('#File1').val()) { /* There are files */ }
Instead of jQuery, use "required". Only one attribute will check the input = file file or not. Example:
<input type="file" required/>
$('#upload').bind('click', function(e){ if( $('#File1').val() != ""){ // file selected } else{ // no file selected } });