[solved] jquery form validation - how to run it when there is no button type submit? |
[eluser]SPeed_FANat1c[/eluser]
Hi, I have a button: Code: <input class = "save" type="button" value="Išsaugoti" /> As you can see the type is not submit, it is just button. This is because I want to not allow submission if javascript is disabled. To submit I run this code: Code: $('input.save').click(function() { When the button type is submit and I run this code Code: $(".edit").validate({ I don't find in google and in documentation how to run it when button is not submit type. Can you help me?
[eluser]smilie[/eluser]
On first look, your jQuery should run. However: document.myform.submit(); is your form really called "myform"? Have you tried using same code as in edit button: form.submit(); instead? Cheers, Smilie
[eluser]SPeed_FANat1c[/eluser]
[quote author="smilie" date="1295905119"]On first look, your jQuery should run. However: document.myform.submit(); is your form really called "myform"? Have you tried using same code as in edit button: form.submit(); instead? Cheers, Smilie[/quote] Yea, the name attribute is myform. I tried form.submit(); instead document.myform.submit(); but it return an error Uncaught ReferenceError: form is not defined. With Code: document.myform.submit(); the form is submitted, but is not validated. Edit: found the answer Here it is: http://docs.jquery.com/Plugins/Validatio...dator/form And here is how my code looks: Code: $('input.save').click(function() { So it actually was in documentation, just was difficult to find. Edit2: thanks for trying to help Edit3: damn, actually now everything does work valination works now, but submission doesn't. Somehow I missed this, thought that submission also works. And it does not submit because submitHandler is not executed if the form is valid. Code: submitHandler:function(form) { console.log is not writing. Edit4: but found one new thing in documentation which I can do, so modified a code little: Code: $('input.save').click(function() { Now I think it works |
Welcome Guest, Not a member yet? Register Sign In |