![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
js如何判断是否选择附件上传?
<table><tr><TD><inputtype="file"name="fileName"id="fileID"size="50"/></TD></tr></tabl...
<table>
<tr>
<TD><input type="file" name="fileName" id="fileID" size="50" /></TD>
</tr>
</table>
table在form里,选择上传的附件后点提交可以上传。
问题:如果我没有上传附件,点击提交时想在页面提示“请上传附件”。在js里判断,js代码应该怎么写? 展开
<tr>
<TD><input type="file" name="fileName" id="fileID" size="50" /></TD>
</tr>
</table>
table在form里,选择上传的附件后点提交可以上传。
问题:如果我没有上传附件,点击提交时想在页面提示“请上传附件”。在js里判断,js代码应该怎么写? 展开
1个回答
展开全部
我再添加一个button。
<input type="button" id="btn"/>
<script type="text/javascript">
document.getElementById("btn").onclick=function(){
if(document.getElementById("fileID").value==""){
alert("请上传附件");
}
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询