Home > other >  Form submission using Bootstrap forms
Form submission using Bootstrap forms

Time:12-29

I am trying to create a contact us section by using bootstrap forms which emails the inputted data using mailto. But when I submit it, after entering some data, using the submit button Gmail pops up but nothing is entered in it. What should I do so that the data I enter in the form gets entered in the email? this is the code

<form  action="mailto:[email protected]" method="post">

  <div >
    <label for="exampleFormControlInput1" >Email address</label>
    <input type="email"  id="exampleFormControlInput1" placeholder="[email protected]">
  </div>
  <div >
    <label for="exampleFormControlTextarea1" >Example textarea</label>
    <textarea  id="exampleFormControlTextarea1" rows="3"></textarea>
  </div>
<button type="submit" >Submit</button>
</form>

I had the targeted email written in action, I changed it to [email protected] just here.

CodePudding user response:

You need to add the name attribute to each field, which will appear in the mail's body. It'll format itself as mail={your_message} and so on.

Your code becomes:

<form  action="mailto:[email protected]" method="post" enctype="text/plain">
    <div >
        <label for="exampleFormControlInput1" >Email address</label>
        <input type="email"  id="exampleFormControlInput1" placeholder="[email protected]" name="email">
    </div>
    <div >
        <label for="exampleFormControlTextarea1" >Example textarea</label>
        <textarea  id="exampleFormControlTextarea1" rows="3" name="message"></textarea>
    </div>
    <button type="submit" >Submit</button>
</form>

JSFiddle

  • Related