[英]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"> Send </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.