I have a form that lunchs a modal for confirmation before submitting, this modal has the submit button and is not inside the <form>
, is working everywhere besides IE, in IE it just doesnt do anything.
<form action="" id="form" name="form" > // start form
In the modal this is the submit button
<button id="btnSend" type="submit" form="form">OK</button>
Tried to add a hidden submit button in the form as suggestted in other post but didnt work.
I have a form that lunchs a modal for confirmation before submitting, this modal has the submit button and is not inside the <form>
, is working everywhere besides IE, in IE it just doesnt do anything.
<form action="" id="form" name="form" > // start form
In the modal this is the submit button
<button id="btnSend" type="submit" form="form">OK</button>
Tried to add a hidden submit button in the form as suggestted in other post but didnt work.
Share Improve this question edited Apr 11, 2017 at 18:03 DontVoteMeDown 21.5k10 gold badges72 silver badges113 bronze badges asked Apr 11, 2017 at 18:00 Tyra PululiTyra Pululi 4461 gold badge8 silver badges19 bronze badges 1-
You could try posting the form with js in case of IE:
document.getElementById('form').submit()
. Just trigger this code when user clicks the modal confirmation button. – DontVoteMeDown Commented Apr 11, 2017 at 18:04
2 Answers
Reset to default 5The form
attribute does not supported by IE or Edge. So, you should handle click action and submit your form manually to support cross browser.
You also needs to add a hidden submit button in your form if you want end user submit form when press enter
on input fields..
document.getElementById('btnSend')
.addEventListner('click', function (event) {
document.getElementById('form').submit();
})
;
edit: Overview of Browsers supporting form-attribute caniuse
$(document).on('click', '#btnSend', function() {
$('#form').submit();
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" id="form" name="form" onSubmit="alert('submitted')"></form>
<button id="btnSend" type="submit" form="form">OK</button>