A
A
Artyom2016-04-14 12:27:28
JavaScript
Artyom, 2016-04-14 12:27:28

Will data be sent?

There is a contact form in a modal window. Two buttons: submit and cancel.
On cancel , form clearing is screwed:

function myFunction() {
            document.getElementById("feedback").reset();
        }

Works fine. But how to implement cleanup after sending on sumbit?
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel" class="text-center">Напишите нам!</h3>
          </div>
          <div class="modal-body clearfix">
            <form id="feedback" class="form-horizontal col-sm-12" role="form" action="https://formspree.io/%mail%" method="POST">
              <div class="form-group">
                  <label>Имя</label>
                  <input name="name" class="form-control required" placeholder="Ваше имя" data-placement="top" data-trigger="manual" data-content="" type="text" required>
             </div>
              <div class="form-group">
                  <label>Сообщение</label>
                  <textarea name="message" class="form-control" placeholder="Ваше сообщение..." data-placement="top" data-trigger="manual" required></textarea>
              </div>
              <div class="form-group">
                  <label>E-Mail</label>
                  <input name="_replyto" class="form-control email" placeholder="Ваш e-mail, чтобы мы могли связаться с вами" data-placement="top" data-trigger="manual" data-content="" type="email" required>
                  <input type="text" name="_gotcha" style="display:none" />
                  <input type="text" name="_format" value="plain" style="display:none" />
                  <input type="hidden" name="_subject" value="Новое сообщение!" />
                  <input type="hidden" name="_next" value="none" />                  
              </div>
              <div class="form-group">
                  <label>Телефон</label>
                  <input name="phone" class="form-control" placeholder="Ваш телефон" data-placement="top" data-trigger="manual" data-content="" type="tel">
              </div>
              <div class="form-group">
                <button type="submit" class="btn btn-success pull-left">Отправить</button>
                <button class="btn btn-default mCancel pull-right" data-dismiss="modal" aria-hidden="true" onclick="myFunction()">Отмена</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
entermix, 2016-04-14
@entermix

Do a reset() after submitting the form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question