I can not prevent the submit
button from performing your action if the information you entered is not the same, could someone help me?
HTML
<form method="post" action="php/cadastro.php">
<span class="form_title">Cadastre-se</span>
<fieldset>
<input type="text" name="nome" class="txt_input first_input" placeholder="Nome">
<input type="email" name="email" class="txt_input" id="email" placeholder="E-mail">
<input type="email" name="confirmaEmail" class="txt_input" id="confirma-email" placeholder="Confirmar e-mail">
<input type="password" name="senha" class="txt_input" id="senha" placeholder="Senha">
<input type="password" name="confirmaSenha" class="txt_input" id="confirma-senha" placeholder="Confirmar senha">
</fieldset>
<fieldset>
<input type="checkbox" name="termos">
<p>Eu concordo com os <span>termos de uso e política de privacidade</span> do WEB TRAINING</p>
</fieldset>
<fieldset class="buttons">
<input type="submit" name="Cadastrar" value="Cadastrar" class="log_btn" id="cadastro-btn" onclick="valida()">
<input type="button" name="Voltar" value="Voltar" class="log_btn volta_btn" id="volta-btn" onclick="voltar()">
</fieldset>
</form>
Javascript
var email = document.getElementById('email');
var confirmaEmail = document.getElementById('confirma-email');
var senha = document.getElementById('senha');
var confirmaSenha = document.getElementById('confirma-senha');
var cadastrar = document.getElementById('cadastro-btn');
function valida(){
if(email != confirmaEmail || senha != confirmaSenha){
cadastrar.preventDefault();
}
};
* The script is already linked at the end of HTML * I tried the forms you sent, but none worked