1
I’m checking a form with the onsubmit
, but even returning true
He gives the Shadow.
Follows the function calling on 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;
}
It is to return true only if the Ext answer is yes, it enters the if that checks it (it gives the innerHTML in p) but it still doesn’t give the Ubmit in the form. Below is the form and how Onsubmit is made:
<form name="formSenha" role="form" onsubmit="return checkFormModal()" class="form" action="../Controller/editaSenhaUsuario.php" method="POST" autocomplete="off">
I would like to know why it does not give true Return. Thank you from now.
There is no treatment for action, just the push of the button
submit
. You are using Ajax. so try to empty the action attribute and redirect with javascript..– Guilherme Rigotti
@Guilhermerigotti, put the Submit button action empty? Because clicking the button is the only way to give the Submit in this form.
– Leonardo Walbrinch
You know that the form will submit if it is returned true, right?
– Jorge.M
yes, and that’s exactly what’s not happening. He gives the innerHTML no p, IE, entered the if that of the true Return, and yet he does not give the Submit
– Leonardo Walbrinch
Leave your onsubmit like this:
onsubmit="return checkFormModal()"
– Jorge.M
had already made this issue, but still has the same problem.
– Leonardo Walbrinch
Where is the function
CriaRequest()
?– Sam
It’s in the same file, but I didn’t put it here because at first this part is working. If you deem it necessary I can edit the question and put this function together.
– Leonardo Walbrinch