Js determines upload file type determines FileUpload file type code

  • 2020-03-30 03:02:07
  • OfStack

Asp.net HTML tag code:
<asp:FileUpload ID="fuMain" runat="server" /> 
<asp:Button ID="btnUpload" runat="server" OnClientClick="return CheckWorkFile()" Text=" upload " /> 

Normal HTML tags:
<input type="file" ID="fuMain" /> 
<input type="button" ID="btnUpload" onclick="return CheckWorkFile()" Text=" upload " /> 

For ASP.NET or plain HTML tags, the following JS code applies:
function CheckWorkFile() 
var obj=document.getElementById('fuMain'); 
alert(' Please select the assignment book file to upload '); 
return false; 
var stuff=obj.value.match(/^(.*)(.)(.{1,8})$/)[3]; 
alert(' Incorrect file type, please select .doc file '); 
return false; 
return true; 

Related articles: