gpt4 book ai didi

javascript - Bootstrap 模式表单未提交

转载 作者:行者123 更新时间:2023-12-01 01:57:42 25 4
gpt4 key购买 nike

我有以下与 Bootstrap 模式表单相关的 html 代码。当用户关注特定文本字段并按 Enter 键时,不会提交表单。相反,如果我删除两个“输入”标签(名字或姓氏)之一,它就会起作用(并且显示警报)。怎么可能?

<html>
<head>
<link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
<div class="modal fade" id="modal-user" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Enter your name</h4>
</div>
<div class="modal-body">
<form id="contact_form" action="javascript:alert('test')"
method="POST">
First name: <input type="text" name="first_name"><br />
Last name: <input type="text" name="last_name"><br />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" id="submitForm" class="btn btn-default">Send</button>
</div>
</div>
</div>
</div>

<!-- jQuery -->
<script src="../vendor/jquery/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="../vendor/bootstrap/js/bootstrap.min.js"></script>

</body>

</html>

最佳答案

将发送按钮放入表单中并使其type='submit'

关于javascript - Bootstrap 模式表单未提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50881767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com