zoukankan      html  css  js  c++  java
  • javascript在Asp.net验证上传文件的文件类型的

    <%@ Page Language="C#" MasterPageFile="~/VQPMaster.master" AutoEventWireup="true" CodeFile="importQuotation.aspx.cs" Inherits="ImportExcel_importQuotation" Title="Untitled Page" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">
    <script type="text/javascript" src="../js/jquery-1.5.2.js"></script>
    <script language="javascript" type="text/javascript">

    $(document).ready(
    function(){
    var fileUpload = $("#<%=fileUpload.ClientID%>");
    var txtEmail = $("#<%=txtEmail.ClientID%>");
    var lblMessage = $("#<%=lblMessage.ClientID%>");
    lblMessage.text();
    $(
    "#<%=btnSubmit.ClientID%>").click(function(){
    if(fileUpload.val() == ""){
    fileUpload.focus();
    lblMessage.text(
    "please upload file!");
    return false;
    }
    else // valid the upload file extension file name!
    {
    var hash = {
    '.XLS' : 1,
    '.XLSX' : 1
    };
    var re = /\..+$/;
    var ext = fileUpload.val().toUpperCase().match(re);
    if (!hash[ext]) {
    lblMessage.text(
    "Invalid filename, please select another file!");
    return false;
    }
    }
    if(txtEmail.val() == ""){
    lblMessage.focus();
    lblMessage.text(
    "please input user email!");
    return false;
    }


    })
    $(
    "#btnReset").click(function(){
    lblMessage.text(
    "")
    })
    })
    </script>

    <div id = "divUploadMain" style =" margin : 5px 0px 0px 4%; ">
    <div id= "divFileUpload" style="height : 30px; margin-bottom : 5px;" >
    Quote
    &nbsp;&nbsp;&nbsp;&nbsp;File&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;<asp:FileUpload ID="fileUpload" runat="server" Width="464px" />
    </div>
    <div id = "divEmail" style="height : 30px; margin-top : 5px;">
    MAPS
    &nbsp;Email&nbsp;contact&nbsp;:
    <asp:TextBox ID="txtEmail" runat="server" Width="464px"></asp:TextBox>
    </div>
    <div id="divBtns">
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" />&nbsp;
    <input id="btnReset" type="reset" value="Reset" />&nbsp;
    <asp:Label ID="lblMessage" runat="server" ForeColor="Red" Visible="true" Text=""></asp:Label></div>
    </div>
    </asp:Content>

  • 相关阅读:
    使用springboot缓存
    Something wrong with EnCase v8 index search results
    Is it a full physical image???
    FB的新专利竟要监看使用者的脸
    How to image a CD/DVD ROM and generate hash value
    Mobile game forensics
    物理提取大绝招”Advanced ADB”???
    How to trace the Geolocation of network traffic
    App forensics
    专做手机取证的大厂被人给黑了
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/2044567.html
Copyright © 2011-2022 走看看