I'm checking a form with onsubmit
, but even returning true
it's submit.
Here is the function that calls onsubmit:
function checkFormModal(){
var senhaAtual = document.getElementById("senhaAtu").value;
var alerta = document.getElementById("avisoSenhaDig");
var usuario = document.getElementById("nomeUsuarioTestaSenha").value;
var p = document.getElementById("p");
var xmlreq = CriaRequest();
xmlreq.open("GET", "../Controller/verificaSenhaUsuario.php?senha="+senhaAtual+"&nomeusu="+usuario, true);
xmlreq.onreadystatechange = function(){
if (xmlreq.readyState == 4) {
if (xmlreq.status == 200) {
if (xmlreq.responseText == "nao") {
if (senhaAtual.length > 0) {
return false;
}
return false;
}else if (xmlreq.responseText == "sim"){
p.innerHTML = "true";
return true;
}
}else{
alerta.innerHTML = "ERRO: " + xmlreq.statusText;
return false;
}
}
};
xmlreq.send(null);
return false;
}
This is true only if resposeText is yes, it goes into if that checks for it (it gives the innerHTML in p) but even so it does not give the submit in the form. Here's how the OnSubmit is done:
<form name="formSenha" role="form" onsubmit="return checkFormModal()" class="form" action="../Controller/editaSenhaUsuario.php" method="POST" autocomplete="off">
I wonder why it does not give return true. Thank you in advance.