How I know if my input type=“file” has content selected

前端 未结 3 1795
囚心锁ツ
囚心锁ツ 2021-02-05 05:51

i have a simple input file but I\'m trying to validate after the post if the input file has content.

I

3条回答
  •  故里飘歌
    2021-02-05 06:08

    try to get the value after the form submission like this

    $('#yourform').submit(function(){
         var val = $("#file").val();
        if(val == ''){
           return false;
        }
    });
    

提交回复
热议问题