简体   繁体   中英

How to reset the form data in html using jquery/javascript && and also how to send the form data to an email using jquery?

I'm new to jquery

I'm working on a form data html ,

now i need to reset the data on click on the reset button and also need to transfer the form data to email on click on submit button .

Can anyone help me in solving this??

Before Posting the question I have gone through the link which Pierre C. has updated and my question is different from that question and even how to add /can we add "type" attribute in anchor tag.??

here is the html:

<form id="form" method="post">
  <fieldset>
    <label>
      <input type="text" value="Name">
    </label>
    <label>
      <input type="text" value="Email">
    </label>
    <label>
      <input type="text" value="Phone">
    </label>
    <label>
      <textarea>Message</textarea>
    </label>
    <div class="btns">
      <a href="#" class="button">Clear</a>
      <a href="#" class="button" onClick="document.getElementById('form').submit()">Send</a>
    </div>
  </fieldset>
</form>

To clear all the data within a form, all you have to do is add an

<input type="reset" name="reset" value="Reset"></input>

However, reset buttons are annoying and no one ever uses them, so I suggest you just leave that. With regards to sending the form, the way I would do it is write this app in ASP.NET MVC and just put the mail logic in the controller, or create an API for your app, then create an Ajax POST on the button click using the form data as API parameters.

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