我在javascript中添加了动态文件上传控件 [英] i have added dynamically file upload control in javascript
本文介绍了我在javascript中添加了动态文件上传控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果文件上传控件没有任何文件,如何显示警告框
how to show the alert box if file upload control not having any file
推荐答案
你好,
你可以使用下面的代码,
Hello,
you can use below code,
<input type="file" name="file" id="File1" />
<input type="button" onclick="validatefile()">
</input>
function validatefile()
{
if(
(< span class =code-string>' #File1')。val()!= ){
// 选择文件
alert( 选择文件);
}
其他 {
// < span class =code-comment>未选择文件
alert( 未选择任何文件跨度>);
}
}
('#File1').val() != ""){ // file selected alert("file selected"); } else{ // no file selected alert("no file selected"); } }
这篇关于我在javascript中添加了动态文件上传控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文