1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

执行不了JS,那里错了

本帖由 BoBo2006-03-29 发布。版面名称:前端开发

  1. BoBo

    BoBo New Member

    注册:
    2005-09-29
    帖子:
    929
    赞:
    0
    执行不了JS,那里错了?:lol:

    代码:
    <Script Language="JavaScript">
    <!--
    function isPic(){
    var temp;
    var ExtList = ".jpg.gif.bmp.png.swf";//客户端,检测文件后缀名,省得上传完成后,才报文件类型错误!
    var FileName = UploadForm.FileName.Value 
    var the_ext = FileName.substr(FileName.lastIndexOf(".")+1).toLowerCase();
    if (ExtList.indexOf(the_ext)==-1){
    alert("不是图片,请选择图片文件!");
    return false;
    }
    return true;
    }
    //-->
    </Script>
    
    <Form Name="UploadForm" Method="post" Enctype="multipart/form-data" Action="?act=upload">
    <Input Name="FileName" Type="FILE" Size="26"><Input Name="Submit" Type="submit" Value="上 传" OnClick="return isPic();"></Form>
     
  2. Function

    Function New Member

    注册:
    2006-03-24
    帖子:
    3,884
    赞:
    5
    代码:
    <Script Language="JavaScript">
    <!--
    function isPic(){
    var temp;
    var ExtList = ".jpg.gif.bmp.png.swf";//客户端,检测文件后缀名,省得上传完成后,才报文件类型错误!
    //var FileName = UploadForm.FileName.Value 
    var FileName = document.getElementById("FileName").value;
    var the_ext = FileName.substr(FileName.lastIndexOf(".")+1).toLowerCase();
    if (ExtList.indexOf(the_ext)==-1){
    alert("不是图片,请选择图片文件!");
    return false;
    }
    return true;
    }
    //-->
    </Script>
    
    <Form Name="UploadForm" Method="post" Enctype="multipart/form-data" Action="?act=upload">
    <Input Name="FileName" id="FileName" Type="FILE" Size="26"><Input Name="Submit" Type="submit" Value="上 传" OnClick="return isPic();"></Form>