Perché usi un tasto submit che processa comunque la action del form.
soluzione con submit:
con button:codice:<script type="text/javascript"> function cbCheck(){ cbObj = document.getElementById('cb'); if (!cbObj.checked){ alert("Devi accettare le condizioni per procedere oltre"); return false; } } </script> <form id="form1" name="form1" method="post" action="manda.html" onsubmit="return cbCheck()"> <label> <input type="checkbox" name="privacy" id="cb" /> </label> <label> <input type="submit" name="button" id="button" value="Controlla" /> </label> </form>
codice:<script type="text/javascript"> function cbCheck(){ cbObj = document.getElementById('cb'); if (!cbObj.checked){ alert("Devi accettare le condizioni per procedere oltre"); }else{ document.form1.submit() } } </script> <form id="form1" name="form1" method="post" action="manda.html"> <label> <input type="checkbox" name="privacy" id="cb" /> </label> <label> <input type="button" name="button" id="button" value="Controlla" onclick="cbCheck()" /> </label> </form>![]()
P.S. Sbaglio o lo studio non è il tuo forte?![]()

Rispondi quotando