Limit file format when using <input type=“file”>?

前端 未结 11 2197
盖世英雄少女心
盖世英雄少女心 2020-11-22 04:15

I\'d like to restrict the type of file that can be chosen from the native OS file chooser when the user clicks the Browse button in the

11条回答
  •  粉色の甜心
    2020-11-22 04:54

    I know this is a bit late.

    function Validatebodypanelbumper(theForm)
    {
       var regexp;
       var extension =     theForm.FileUpload.value.substr(theForm.FileUpload1.value.lastIndexOf('.'));
       if ((extension.toLowerCase() != ".gif") &&
           (extension.toLowerCase() != ".jpg") &&
           (extension != ""))
       {
          alert("The \"FileUpload\" field contains an unapproved filename.");
          theForm.FileUpload1.focus();
          return false;
       }
       return true;
    }
    

提交回复
热议问题