How can the file extension be validated in an input type file using JQuery?

后端 未结 4 1198
后悔当初
后悔当初 2021-01-22 02:35

HTML:


Rule: The file to

4条回答
  •  盖世英雄少女心
    2021-01-22 02:57

    The following gets the extension of the file:

    JS:

    $('#group_documents_file').change(function(){
        var value = this.value;
        val = value.split("\\");
        var file = (val[val.length - 1]).split('.');
        var ext = file[file.length - 1];
        alert(ext);
    })
    

    Fiddle: http://jsfiddle.net/maniator/gveqX/

提交回复
热议问题