简体   繁体   中英

How i can add onsubmit attribute to <form> in contact form 7 and onclick attribute to the submit button in contact form 7

This is my HTML code:

<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>

How i can implement this in contact form 7 of my wordpress website. Also i have multiple forms on same page so please help how i can target a specific form with the above mentioned attributes..???

Here is how you can achieve it :

<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>

Explanation :

I have replace type="submit" by type=button so that it doesn't submit the form. If you need to submit a form you can proceed this way onclick="form_id.submit()" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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