mam formularz
<form action="dodaj.php" method="POST" onsubmit="return checkform(this);">
i wywolanie tej funkcji:
function checkform ( form ) {
jak to przerobic zgodnie ze standardami, zeby pozbyc sie z formularza tego onsubmit?
<form action="dodaj.php" method="POST" onsubmit="return checkform(this);">
function checkform ( form ) {
<form action="dodaj.php" method="POST" id="formularz">
$("#formularz").submit(function(e){ ...sprawdzenie... if (blad) { return false; } });
var form = false; $("#formularz").submit(function(e) { if (form == false ){ alert('STOP'); return false; } return true; });
<html> <head> <script type="text/javascript"> $(document).ready(function(){ $("#formularz").submit(function(e){ alert('tutaj'); if ($("#pole").val() == '') { alert('zle'); e.preventDefault(); //return false; } else { alert('dobrze'); return true; } }); }); </script> </head> <body> <form action="plik.php" method="post" id="formularz"> <input type="text" name="pole" value="" id="pole" /> <input type="submit" value="wyslij" /> </form> </body> </html>
var form = false; var form2 = false; if (!form && !form2) { alert('zle'); e.preventDefault(); //return false; } else { alert('dobrze'); return true; }