theflarenet theflarenet - 5 days ago 6
jQuery Question

Resume Form Submit after PreventDefault

I've looked around and found many similar answers but the form submit I have within my code fails. What seems to be missing or incorrect that prevents the form to submit when either 'submit' buttons are clicked and confirmed with SweetAlert?

http://plnkr.co/edit/NL7r4E9UKVjGSBbAwt86?p=preview

<form id='submissionForm' autocomplete='off' method='POST'>
<button>Save</button>
<input type='submit' name='submit' id='submitTest1' value='Submit 1'>
<input type='submit' name='submit' id='submitTest2' value='Submit 2'>
</form>


Clicking "Yes, I am sure" then "Ok" doesn't submit the form.

UPDATE:
I've simplified the code: http://plnkr.co/edit/A9aDycYhIkJcTmK5qIUS?p=preview

Answer

The form element has a method named submit, but also has the form elements in the form as members.

If you have a button in the form named submit, you could access it using document.form1.submit. However, as that is the same name as the submit method, there is no longer any way of accessing that method. If you use the method to submit the form, that will no longer work.

Use this plunker:

HTML:

<form id='submissionForm' autocomplete='off' method='POST'>
        <button>Save</button>

        <input type='submit' name='submit1' id='submitTest1' value='Submit 1'>
        <input type='submit' name='submit2' id='submitTest2' value='Submit 2'>
    </form>
Comments