【发布时间】:2019-06-15 16:20:14
【问题描述】:
我的 html 页面带有一个表单,在提交时调用一个 javascript 函数来检查一些值:
html:
<form onsubmit="isempty();" role="form">
isempty():
function isempty() {
var r_1;
var r_2;
var r_3;
r_1 = document.getElementById("t_select");
r_2 = document.getElementById("t_descr");
r_3 = document.getElementById("t_terms");
if((r_1.value == "Please select...") || (r_2.value == "") || (r_3.checked == false)) {
alert("Please fill in all the form fields including the terms of use to proceed with the publication");
return false;
} else {
//OK
}
}
所有工作都完成了,唯一的问题是在检查失败的情况下,页面显示警报然后重新加载,清除所有预览插入的数据。 如何在失败时显示警报然后冻结页面(不重新加载)?
提前非常感谢
【问题讨论】:
标签: javascript html