• 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>

  • 相关阅读:
    java.math.BigDecimal
    抽象类和接口的区别:
    idea 快捷键
    java 抽象类
    mongodb3.2系统性学习——5、游标 模糊查询 findAndModify函数
    ZeroClipboard2.0 复制功能
    MySQL在远程访问时非常慢的解决skip-name-resolve 并且出现 Reading from net
    mongodb3.2系统性学习——2、write concern mongodb 写安全机制
    mysql 存储引擎 myisam innodb 区别
    MYSQL 错误 :Out of resources when opening file './datagather/mx_domain#P#p178.MYD' (Errcode: 24) 解决办法
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/2044567.html
Copyright © 2020-2023  润新知