简体   繁体   English

从模式引导程序提交表单

[英]Submit form from a modal bootstrap

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> ,除了IE之外,它都在其他地方工作,在IE中它什么都不做。

<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. 试图按照其他帖子中的建议在表单中添加一个隐藏的提交按钮,但是没有用。

The form attribute does not supported by IE or Edge. IE或Edge不支持form属性。 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.. 如果希望最终用户在输入字段上按enter键时提交表单,则还需要在表单中添加一个隐藏的提交按钮。

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.com/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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM