zoukankan      html  css  js  c++  java
  • 用CustomerValidator 来验证 FileUpload控件的方法

    How to check the FileUpload control on Client code(Brower)
    First the FileUpload control is support Validator control
    so we can use RegularExpressionValidator, CustomerValidator, because we can't set Ignore case property on Regular Expression Validator , so  i like use CustomerValidator to check the Extension.
    The code on below, you can copy the code block to your page, and add one CustomerValidator

     <script type="text/javascript">
    function CheckFile(sender,arg)
    {
        
    var enableExt =["jpg","gif","bmp","png"]; // add your enable extension on that
        if (arg.Value=="")
        
    {
            arg.IsValid 
    =true;
        }

        
    else
        
    {
            
    var temp = arg.Value.split(".");
            
    var extension = temp[temp.length-1];
            extension 
    = extension.toLowerCase();
            
    var isValid = false;
            
            
    for(i=0;i<enableExt.length;i++)
            
    {
               
    if (extension==enableExt[i])
               
    {
                    isValid
    =true;
               }

            }

            arg.IsValid 
    = isValid;
        }

    }

    </script>
  • 相关阅读:
    python的metaclass
    鱼和水的故事
    iOS的QuickTime Plugin
    二进制/十六进制转浮点数的编程(互转类似)
    Android开发常见错误及技巧
    Mac 热键大全
    Java动态程序设计:反射介绍
    注册asp.net 4.0 到iis
    javascript常用判断写法
    将存储过程执行的结果保存到临时表
  • 原文地址:https://www.cnblogs.com/lovebanyi/p/1186301.html
Copyright © 2011-2022 走看看