<form id="login" class="form-horizontal" action="login_login.action" onsubmit="return validate();" method="post">
</form>
function validate(){
alert("Please enter the verification code!"); //Then please enter the verification code
return false;
}
else if(inputCode != code ) {
alert("The verification code is wrong! @_@") ; //The verification code input error will pop up
createCode();//Refresh the verification code
document.getElementById("verificatCode").value = "";//Clear the text box
return false;
}
else {//If the input is correct,
return true ;
}
}
The writing of onsubmit in the form must be "return method ()", but only "method ()" will not work. And if there is a return value, if it returns false, it will prevent the submission, and if it returns true, it will not. The wrong spelling is:
<form id="login" class="form-horizontal" action="login_login.action" onsubmit="validate();" method="post">
</form>