用js判断空值问题不知道少什么
这是js
function imgCheck(){
if(document.getElementById('myFile').value==""){
alert("请选择上传文件");
return false;
}else{
return true;
}
这是我需要检查空值的
<form method="post" enctype="multipart/form-data"
action="CuploadAction.action">
替换图片:
<input id="myFile" type="file" size="20" name="myFile"></input>
<input type="submit" value="替换图片"></input>
</form>
<form method="post" enctype="multipart/form-data"
action="DuploadAction.action" onsubmit="return imgCheck()">
现在我就算选了图片也会报出请选择上传文件,不知道还需要加什么图书管理系统论文
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> <!-- function imgCheck(form){ var fileInput = form["myFile"]; if(fileInput.value==""){ alert("请选择上传文件"); return false; }else{ return true; } } //--> </script> <form method="post" enctype="multipart/form-data"action="DuploadAction.action" onsubmit="return imgCheck(this)"> <input type="file" size="20" name="myFile"></input> <input type="submit" value="替换图片1"></input> </form> <form method="post" enctype="multipart/form-data"action="DuploadAction.action" onsubmit="return imgCheck(this)"> <input type="file" size="20" name="myFile"></input> <input type="submit" value="替换图片2"></input> </form> <form method="post" enctype="multipart/form-data"action="DuploadAction.action" onsubmit="return imgCheck(this)"> <input type="file" size="20" name="myFile"></input> <input type="submit" value="替换图片3"></input> </form>