我试图确保某些字段在我的表单中不留空白。它似乎很简单,但由于某种原因,它不起作用。警报没有显示,并返回false不起作用(它继续发布到我的数据库空白条目)请帮助,我做错了什么。谢谢!Javascript返回false,警告不起作用
脚本:
function check(){
var name = getElementById('name');
var date = getElementById('date');
var pri = getElementById('pri');
var asapc = getElementById('asapc');
var asapn = getElementById('asapn');
var obr = getElementById('obr');
var obc = getElementById('obc');
var obn = getElementById('obn');
if (name.value == "" || date.value == "" || pri.value == "not" || asapc.value == "" || asapn.value == "" || obr.value == "" || obc.value == "" || obn.value == "") {
alert("One or more fields were not filled out.");
return false ; }
return true;
}
代码:
<FORM ACTION="step2.php" METHOD="POST" onsubmit="check();">
<!-- fields here -->
<INPUT TYPE="submit" VALUE="CONTINUE">
假设一个领域是空白,切忌警报仍火? – j08691 2012-08-17 16:51:40