0

this is a simple html form and am trying to link it with javascript code so that the user can be able to send a message to contact my client.

      <div class="container">

        <div class="form">

          <div id="sendmessage">Your message has been sent. Thank you!</div>

          <div id="errormessage"></div>

          <form action="" method="post" role="form" class="contactForm">

            <div class="form-row">

              <div class="form-group col-md-6">

 <input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
                <div class="validation"></div>
              </div>
              <div class="form-group col-md-6">
                <input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
                <div class="validation"></div>
              </div>
            </div>
            <div class="form-group">
          <input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" data-rule="minlen:4" data-msg="Please enter at least 8 chars of subject" />

          <div class="validation"></div>

            </div>
            <div class="form-group">
         

 <textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea>
              <div class="validation"></div>
            </div>
            <div class="text-center"><button type="submit">Send Message</button></div>
          </form>
        </div>

      </div>

I don't know if I should use php for that or javascript, or if there is any library that can help me to simplify my work

1 Answers1

0

You can use both PHP or JavaScript to sending data to the server. If you use PHP, then you should specify form action, if you leave it empty, your data will be sent to the current page. Also, you can send data by javascript or other related libraries like jQuery. In this case you can use XMLHttpRequest or ajax

Erfan Atp
  • 169
  • 8