Javascript 返回false;单击“提交”按钮不工作
我一直试图让我的提交按钮返回假,如果我的代码中有任何错误,但它不断带我到一个坏页,我已经尝试在firefox控制台,没有错误。谢谢 返回值false位于底部 代码: 试试这个代码Javascript 返回false;单击“提交”按钮不工作,javascript,onclick,submit,Javascript,Onclick,Submit,我一直试图让我的提交按钮返回假,如果我的代码中有任何错误,但它不断带我到一个坏页,我已经尝试在firefox控制台,没有错误。谢谢 返回值false位于底部 代码: 试试这个代码 function searchForm(){ //checks all the boxes to see if there are any errors confirmFName(); confirmLName(); confirmEmail(); confirmAddress1(); confirmAddre
function searchForm(){
//checks all the boxes to see if there are any errors
confirmFName();
confirmLName();
confirmEmail();
confirmAddress1();
confirmAddress2();
confirmCity();
confirmCode();
confirmUName();
confirmPass();
var flag=true;
//check to make sure a region is selected
if(nhlForm.regBox == "Choose a Country first", "Choose your Country First"){
//shows error message
showMessage(nhlForm.regBox, "error", "*Choose a region");
showMessage(nhlForm.counBox, "error", "*Choose a country");
flag=false;
}
//checks if checkbox is checked, if not messgae will appear and form will not send
if(nhlForm.agebox.checked == true){
showMessage(nhlForm.agebox, "bingo", "");
}else{
//shows error message
showMessage(nhlForm.agebox, "error", "You must be at least 14 to have an account");
flag=false;
}
if(nhlForm.checkbox.checked == true){
showMessage(nhlForm.checkbox, "bingo", "");
}else{
//shows error message
showMessage(nhlForm.checkbox, "error", "You must accept the terms of use to continue");
flag=false;
}
return flag;
}
和onSubmit=“return searchForm()”在表单标记中,您必须向我们展示该函数是如何调用的。请显示该函数在何处调用。。或者请给我们看把小提琴
function searchForm(){
//checks all the boxes to see if there are any errors
confirmFName();
confirmLName();
confirmEmail();
confirmAddress1();
confirmAddress2();
confirmCity();
confirmCode();
confirmUName();
confirmPass();
var flag=true;
//check to make sure a region is selected
if(nhlForm.regBox == "Choose a Country first", "Choose your Country First"){
//shows error message
showMessage(nhlForm.regBox, "error", "*Choose a region");
showMessage(nhlForm.counBox, "error", "*Choose a country");
flag=false;
}
//checks if checkbox is checked, if not messgae will appear and form will not send
if(nhlForm.agebox.checked == true){
showMessage(nhlForm.agebox, "bingo", "");
}else{
//shows error message
showMessage(nhlForm.agebox, "error", "You must be at least 14 to have an account");
flag=false;
}
if(nhlForm.checkbox.checked == true){
showMessage(nhlForm.checkbox, "bingo", "");
}else{
//shows error message
showMessage(nhlForm.checkbox, "error", "You must accept the terms of use to continue");
flag=false;
}
return flag;
}