简体   繁体   English

html表单提交原因“由于未连接表单而取消了表单提交”

[英]html form submit cause “Form submission canceled because the form is not connected”

I have the following HTML Form displayed, and I would like to call the javascript function sendMail() when the user clicks on the Send button: 我显示了以下HTML表单,当用户单击“发送”按钮时,我想调用javascript函数sendMail():

<script type="text/template" id="compose-view-template">
<form id="email-compose" class="form-email-compose" method="get" action="javascript:sendMail();">
    <div class="form-group">
        <input type="email" id="input-to" placeholder="To" class="input-transparent form-control"
               value="<%= receiver %>">
    </div>
    <div class="form-group">
        <input type="text" id="input-subject" placeholder="Subject" class="input-transparent form-control"
               value="<%= subject %>">
    </div>
    <div class="form-group">
        <textarea rows="10" class="form-control" id="wysiwyg" placeholder="Message"><%- body %></textarea>
    </div>
    <div class="clearfix">
        <div class="btn-toolbar pull-xs-right">
            <button type="reset" id="compose-discard-button" class="btn btn-gray">Cancel</button>
            <button type="submit" id="compose-send-button" onclick="" class="btn btn-danger">&nbsp;&nbsp;&nbsp;Send&nbsp;&nbsp;&nbsp;</button>
        </div>
    </div>
</form>

and the Javascript function: 和Javascript函数:

function sendMail(){

console.log("submit new email");

}
</script> 

but when I click on Send, I have the following error 但是当我单击发送时,出现以下错误

Form submission canceled because the form is not connected 由于未连接表单,因此取消了表单提交

even if I mention an action to the form or to the button onclick I still have the same error. 即使我对表单或按钮onclick提及了一项操作,我仍然遇到相同的错误。 anybody knows how I can solve this issue ? 有人知道我该如何解决这个问题?

Here is a sample of html page, which there is a button on it, and when u click on it, a javascrippt function shows up, and write a message on your page for you. 这是html页面的示例,上面有一个按钮,当您单击它时,将显示一个javascrippt函数,并为您在页面上写一条消息。

Notice: 注意:

To send a real email, you must make a backEnd code for it. 要发送真实的电子邮件,您必须为其编写一个后端代码。

  <script> function sendRequest(){ console.log( "complete the function"); document.getElementById("data").innerHTML = "Email is sent!"; } </script> 
  <!DOCTYPE html> <html> <body> <button type="button" onClick="sendRequest()" >Click me </button> <p id="data"> <p> </body> </html 

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

相关问题 错误:由于表单未连接,表单提交被取消 - Error: Form submission canceled because the form is not connected 表单提交已取消,因为该表单未在GWT上连接 - Form submission canceled because the form is not connected on GWT 由于未连接表单,因此取消了表单提交 - Form submission canceled because the form is not connected 由于未连接表单,因此取消了提交表单的操作 - Getting Form submission canceled because the form is not connected Angular 2:表单提交因表单未连接而取消 - Angular 2: Form submission canceled because the form is not connected React - 由于表单未连接而取消表单提交 - React - Form submission canceled because the form is not connected 在“提交”按钮中添加routerLink进行登录时,“由于未连接表单而取消了表单提交”错误 - A `Form submission canceled because the form is not connected` Error when adding a routerLink in the submit button for log in 收到错误“由于表单未连接而取消表单提交” - Getting Error "Form submission canceled because the form is not connected" 警告“由于未连接表单而取消了表单提交” - warning “Form submission canceled because the form is not connected” in angular 控制台错误:“由于未连接表单而取消了表单提交” - Console error: “Form submission canceled because the form is not connected”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM