javaScript上传文件判断

function CheckUpload()
    {
           var val = $("ctl00_ContentPlaceHolder1_FileUpload1").value;
           if(val == "")
           {
              alert("请选择上传附件。");return false;
           }
           var validateFormat = new Array("txt","xls","ppt","doc","jpg","gif","dxg","dxf","dwt","zip","rar","cdr","pdf");
          
           var fileFormat = val.substring(val.lastIndexOf(".")+1).toLowerCase();
           var validate = false;
           for (var i = 0; i < validateFormat.length ; i++)
           {
                  if(fileFormat == validateFormat[i])
                  {
                        validate = true; break;
                  }
            }
           if (validate == false){alert("上传文件格式非法,请重新选择!"); return false;}
    }

posted @ 2008-06-13 08:57  Shapley  阅读(1105)  评论(2编辑  收藏  举报