我如何将 onsubmit 属性添加到联系表单 7 中的 <form> 并将 onclick 属性添加到联系表单 7 中的提交按钮
How i can add onsubmit attribute to <form> in contact form 7 and onclick attribute to the submit button in contact form 7
这是我的 HTML 代码:
<form id="form" onsubmit="return false;">
<input type="text" id="userInput" />
<input type="email" id="emailId" />
<input type ="number" id="phoneNumber" />
<input type="submit" onclick="userdetails();" />
</form>
我如何在我的 wordpress 网站的联系表 7 中实现这一点。另外我在同一页面上有多个表单,所以请帮助我如何定位具有上述属性的特定表单..???
这是实现它的方法:
<form id="form1">
<input type="text" id="userInput">
<input type="email" id="emailId" />
<input type ="number" id="phoneNumber" />
<input type="button" onclick="userdetails();" value="Details"/>
</form>
<form id="form2">
<input type="button" onclick="form1.submit()" value="Send" />
</form>
解释:
我已将 type="submit"
替换为 type=button
,这样它就不会提交表单。
如果您需要提交表格,可以按此方式进行 onclick="form_id.submit()"
。
这是我的 HTML 代码:
<form id="form" onsubmit="return false;">
<input type="text" id="userInput" />
<input type="email" id="emailId" />
<input type ="number" id="phoneNumber" />
<input type="submit" onclick="userdetails();" />
</form>
我如何在我的 wordpress 网站的联系表 7 中实现这一点。另外我在同一页面上有多个表单,所以请帮助我如何定位具有上述属性的特定表单..???
这是实现它的方法:
<form id="form1">
<input type="text" id="userInput">
<input type="email" id="emailId" />
<input type ="number" id="phoneNumber" />
<input type="button" onclick="userdetails();" value="Details"/>
</form>
<form id="form2">
<input type="button" onclick="form1.submit()" value="Send" />
</form>
解释:
我已将 type="submit"
替换为 type=button
,这样它就不会提交表单。
如果您需要提交表格,可以按此方式进行 onclick="form_id.submit()"
。