I have a form. After clicking the Submit button, I want the message to appear under the form that the data has been sent. How do I saddle with the current markup?

<form id="contact-form" method="post" action=""> <input class="textbox" type="text" name="customerName" id="name" placeholder="Имя" /> <input class="textbox" type="text" name="customerPhone" id="phone" placeholder="Телефон" /> <input class="textbox" type="text" name="customerEmail" id="email" placeholder="Email" /> <textarea class="textbox" name="customerRequest" id="message" placeholder="Комментарий" style="height: 25px;"></textarea> <br /> <div class="full-width"> <input type="checkbox" />Я согласен с условиями политики конфиденциальности. <a href="#">Подробнее</a> </div> <br /> <button class="button small-btn" type="submit" name="submit" id="submit">Отправить</button> <br /><br /> <p id="message-outcome"></p> </form> 

1 answer 1

 <form id="contact-form" method="post" action="" "onsubmit=showMessage();"> <input class="textbox" type="text" name="customerName" id="name" placeholder="Имя" /> <input class="textbox" type="text" name="customerPhone" id="phone" placeholder="Телефон" /> <input class="textbox" type="text" name="customerEmail" id="email" placeholder="Email" /> <textarea class="textbox" name="customerRequest" id="message" placeholder="Комментарий" style="height: 25px;"></textarea> <br /> <div class="full-width"> <input type="checkbox" />Я согласен с условиями политики конфиденциальности. <a href="#">Подробнее</a> </div> <br /> <button class="button small-btn" type="submit" name="submit" id="submit">Отправить</button> <br /><br /> <p id="message-outcome" style="display:none;">Ваше сообщение отправлено!</p> </form> <script> function showMessage() { message = document.getElementById("message-outcome") message.style.display = "block" } </script> 

This is if you want to show an informational message that the form has been submitted.

  • You, what, the page does not reload? - Visman
  • sense from this? The message showed it all? It is necessary that the data were sent processed on the server and returned to success or not! Otherwise, it's all a complete hole in the site - rodgers
  • I use razor, after clicking I check on isPost and then I already send data to the mail. - Den