输入类型文件为空,如何提醒?
这是我的jquery代码,但我不知道如何获得价值
$('.upload').live("click",function() { var imgVal = $('#uploadImage').val(); if(imgVal=='') { alert("empty input file"); } return false; }); <input type="file" name="image" id="uploadImage" size="30" /> <input type="submit" name="upload" class="send_upload" value="upload" />
解决方法
<script type="text/javascript"> $(document).ready(function() { $('#upload').bind("click",function() { var imgVal = $('#uploadImage').val(); if(imgVal=='') { alert("empty input file"); } return false; }); }); </script> <input type="file" name="image" id="uploadImage" size="30" /> <input type="submit" name="upload" id="upload" class="send_upload" value="upload" />