javascript - Submit form from a modal bootstrap - Stack Overflow

I have a form that lunchs a modal for confirmation before submitting, this modal has the submit button

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
Add a ment  | 

2 Answers 2

Reset to default 5

The 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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744383199a4571531.html

相关推荐

  • javascript - Submit form from a modal bootstrap - Stack Overflow

    I have a form that lunchs a modal for confirmation before submitting, this modal has the submit button

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信