执行不了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>
代码: <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>