I follow the suggestion from Find size of file behind download link with jQuery for the file size checking and added return false;
to prevent form submission, but failed . The code as following:
function findSize() {
var fileInput = $("#loadfile")[0];
if (fileInput.files[0].fileSize > 1048 ) {
alert(fileInput.files[0].fileSize);
return false;
}
}
<input type="submit" value="Submit" class="form-submit" onclick="findSize()" />
How do I prevent form submission when file size over limit?
将您签入表单的onsubmit
而不是onclick
-button的onclick
应该可以解决此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.