6
Hello,
I’m having trouble with a page because it’s doing Submit even when validation returns false
.
$("#botao1").click(function() {
$.ajax({
url : 'adicionadaIdeia',
type : 'POST',
async : false,
data : $("#form1").serialize(),
success : document.getElementById("botao2").click(),
});
return false;
});
function validar() {
//Verifica se necessidade tem item selecionado
if($('input[name=Listanecessidade]:checked').length == 0){
alert("Selecione uma necessidade!");
$('input[name=Listanecessidade]').focus();
return false;
}
}
I wanted to know how I avoid the page to make Ubmit in this situation (where the return is false
)
The #boot 1 has the following setting:
<input type="submit" id="botao1" value="Cadastrar">
What HTML element is the
#botao1
? you probably need toe.preventDefault();
And withsubmit
you mean theajax
or the form is reloading the page?– Sergio
the #boot 1 is an input
– Victor Henrique
... with
type=
a ?? Please put html to make the question clearer...– Sergio
<input type="Submit" id="boot 1" value="Register">
– Victor Henrique
Okay, then test with
$("#botao1").click(function(e) { e.preventDefault(); etc...
– Sergio
Victor, click [Edit] and add to the question.
– user28595