This works: form.get(0).onsubmit = function() { if ($("input:first").val() == "correct") { $("span").text("Validated...").show(); return true; } $("span").text("Not valid!").show().fadeOut(1000); return false; }
and somewhere in the action : var form = document.getElementById('smth_id'); if (form.onsubmit()) form.submit(); WTF? Why core js submit() doesn't fire onsubmit action? When you submit form throw interface it fires. On Jan 21, 9:01 pm, ifrond <ifr...@gmail.com> wrote: > Example from documentation > > $("form").submit(function() { > if ($("input:first").val() == "correct") { > $("span").text("Validated...").show(); > return true; > } > $("span").text("Not valid!").show().fadeOut(1000); > return false; > }); > > html: > <p>Type 'correct' to validate.</p> > <form action="javascript:alert('success!');" id="smth_id"> > <div> > <input type="text" /> > <input type="submit" /> > </div> > </form> > <span></span> > > BUT! When you get form throw document.getElementById and submit it by > javascript: > var form = document.getElementById('smth_id'); > form.submit(); > jquery event handler doesn't work > > How to attach event to form by jquery correctly? > > I need it for tinyMCE integration, I think it will be usefull for 3d > party libs integration anyway