0

I am confused as to where to put the "mailto" address in my code below. I would like every comment to be sent to a specific email address, and I would like the name, address and comment sections to be required.

https://jsfiddle.net/turkr/jc74awsc/1/

<div class="container-fluid bg-3 text-left" id="contact">
    <h3 id="contact"><span>CONTACT</span></h3>
    <div class="row">
      <div class="col-sm-5">
        <p>Contact us by..</p>
        <p><span class="glyphicon glyphicon-map-marker"></span> 191 prom du Portage, Gatineau, QC</p>
        <p><span class="glyphicon glyphicon-phone"></span> 613-123-456</p>
        <p><span class="glyphicon glyphicon-envelope"></span> myemail@something.com</p>
      </div>
      <div class="col-sm-7">
        <div class="row">
          <div class="col-sm-6 form-group>
            <input class="form-control" id="name" name="name" placeholder="Name" type="text">
          </div>
          <div class="col-sm-6 form-group">
            <input class="form-control" id="email" name="email" placeholder="Email" type="email">
          </div>
        </div>
        <textarea class="form-control" id="comments" name="comments" placeholder="Comment" rows="5"></textarea><br>
        <div class="row">
          <div class="col-sm-12 form-group">
            <button class="btn btn-default pull-right" type="submit">Send</button>
          </div>
        </div>
      </div>
    </div>
  </div>
Matt
  • 12,848
  • 2
  • 31
  • 53
Rach
  • 17
  • 5

2 Answers2

0

You can use html required attribute

https://www.w3schools.com/tags/att_input_required.asp

Can I set subject/content of email with using mailto:?

You'll have to use javascript to populate the href with the correct mailto content and it is recommended to do this stuff backend instead of using mailto

<div class="col-sm-6 form-group" action>
        <input class="form-control" id="name" name="name" placeholder="Name" type="text" required>
      </div>
      <div class="col-sm-6 form-group">
        <input class="form-control" id="email" name="email" placeholder="Email" type="email" required>
      </div>
    </div>
    <textarea class="form-control" id="comments" name="comments" placeholder="Comment" rows="5" required></textarea>
Rach
  • 17
  • 5
Parker Dell
  • 472
  • 4
  • 11
0

You need a form with an action=somePhpScript.php attribute that sends the form data to the backend, from where you'll send your email. Mailto links are just for opening a new email message in your mail client

Kai
  • 2,529
  • 1
  • 15
  • 24
  • so do I have to redo this one? – Rach Jul 21 '17 at 17:53
  • Yeah, the way it's set up will require javascript to do a number of things that are simpler and more secure to do on the server. If you're using PHP, have a look at this example https://bootcamp-coders.cnm.edu/class-materials/php/email/ – Kai Jul 21 '17 at 17:59