Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to show the alert box if file upload control not having any file
Posted

1 solution

Hello,

you can use below code,
HTML
<input type="file" name="file" id="File1" />
<input type="button" onclick="validatefile()">
</input>

JavaScript
function validatefile()
 {
   if( $('#File1').val() != ""){
       // file selected
      alert("file selected");

   }
   else{
       // no file selected
      alert("no file selected");
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900