- HTML code
<html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <link rel="stylesheet" href="wancfg_data/stylemain.css" type="text/css"> <link rel="stylesheet" href="wancfg_data/colors.css" type="text/css"> <script language="javascript"> <!-- hide var progress = 0; if (document.images) { pic1= new Image(); pic1.src="circle.gif"; } function isInProgress() { var bopregd = '1'; if ( progress == 0 ) { if (bopregd == 1) { progress = 1; return true; } else { alert('No BOP registered, could not upgrade BOP firmware.'); return false; } } alert('Upload frimware is in progress, please wait for a minute.'); return false; } // done hiding --> </script> </head> <body> <blockquote> <form method="post" enctype="multipart/form-data" action="uploadbopfw.cgi" onsubmit="return isInProgress();"> <b class="gentitle">Management </b><br> <br><br> <table border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td>Firmware file: </td> <td><input name="filename" size="15" type="file"></td> </tr> </tbody></table> <p align="center"><input value="Update Firmware" type="submit"></p> </form> </blockquote> </body></html>
在没选文件的时候,直接点Update Firmware要提示。
到底怎么实现?
------解决方案--------------------
function isInProgress() {
if(document.getElementsByTagName("input")[0].value==""){
alert("请先选择一个文件");
return false;
}
var bopregd = '1';
if ( progress == 0 ) {
if (bopregd == 1) {
progress = 1;
return true;
} else {
alert('No BOP registered, could not upgrade BOP firmware.');
return false;
}
}
alert('Upload frimware is in progress, please wait for a minute.');
return false;
}
------解决方案--------------------
- HTML code
<html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <link rel="stylesheet" href="wancfg_data/stylemain.css" type="text/css"> <link rel="stylesheet" href="wancfg_data/colors.css" type="text/css"> <script language="javascript"> <!-- hide var progress = 0; if (document.images) { pic1= new Image(); pic1.src="circle.gif"; } function isInProgress() { if(document.getElementById("myfile").value == ""){alert('a');return false;} //判断是否上传文件 var bopregd = '1'; if ( progress == 0 ) { if (bopregd == 1) { progress = 1; return true; } else { alert('No BOP registered, could not upgrade BOP firmware.'); return false; } } alert('Upload frimware is in progress, please wait for a minute.'); return false; } // done hiding --> </script> </head> <body> <blockquote> <form method="post" enctype="multipart/form-data" action="uploadbopfw.cgi" onsubmit="return isInProgress();"> <b class="gentitle">Management </b><br> <br><br> <table border="0" cellpadding="0" cellspacing="0"> <tbody><tr> <td>Firmware file: </td> <td><input name="filename" size="15" type="file" id="myfile"></td> //加了个ID </tr> </tbody></table> <p align="center"><input value="Update Firmware" type="submit"></p> </form> </blockquote> </body></html>