1. 程式人生 > >input 上傳文件的判斷

input 上傳文件的判斷

alert 上傳文件 ice class inpu code accept art ret

<html>
    <head>
        <meta charset=utf-8>
         <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
         <script type="text/javascript"  src="http://mat1.gtimg.com/libs/jquery2/2.2.0/jquery.js
"></script> <body> <form action="upload.html" method="post" enctype="multipart/form-data" accept-charset="utf-8"> <input id="file" type="file" name="選擇文件"><br/> <input id="fileUpload" type="submit" value="提交"> </form> <script type="
text/javascript"> $("#fileUpload").click(function(){ if($("input[type=‘file‘]").val()==""){ alert("請選擇文件後提交"); return false; }else{ return true
; } }) </script> </body> </html>

空文件就不要讓提交

input 上傳文件的判斷