JS Judge upload file type judge FileUpload file type code _javascript skill

Source: Internet
Author: User
HTML tag code in asp.net:
Copy Code code as follows:

<asp:fileupload id= "Fumain" runat= "Server"/>
<asp:button id= "Btnupload" runat= "Server" onclientclick= "return Checkworkfile ()" text= "Upload"/>

Plain HTML Tags:
Copy Code code as follows:

<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:
Copy Code code as follows:

function Checkworkfile ()
{
var obj=document.getelementbyid (' Fumai n ');
if (obj.value== ')
{
Alert (' Please select the job book file to upload ');
return false;
}
Var stuff=obj.value.match (/^ (. *) (\.) (. {1,8}) $/) [3];
if (stuff!= ' Doc ')
{
Alert (' file type is incorrect, select. doc file ');
return false;
}
return true;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.