There is a form and function of validation. Upon confirmation of the form, onclick="validation_form"
is triggered and a window is displayed with a message about the successful submission of the form. In this box, the "OK" button. By clicking on it, this window should disappear and the form will reappear. The window is displayed, but back when you click on "OK" does not close. The click is processed by console.log()
. But the desired result is not.
Code:
function validation_form() { if (($('#feedback input[name="name"] value') !== '') && ($('#feedback input[name="mail"] value') !== '') && ($('#feedback textarea') !== '')) { $(this).click(function() { $('#feedback form').hide(); $('#feedback-message').show(); }); } } $('.ok-btn').click(function() { $('#feedback form').show(); $('#feedback-message').hide(); console.log('ok-btn pressed'); });
<div id="feedback"> <h1>Обратная связь</h1> <div class="white-border"></div> <form action=""> <input type="text" name="name" placeholder="Введите имя..." required> <input type="text" name="mail" placeholder="Введите эл. почту..." required> <textarea cols="38" rows="6" name="message" placeholder="Введите сообщение..." required></textarea> <img src="../assets/img/reCAPTCHA.png" alt="reCAPTCHA" style="width: 100%;"> <div class="orange-btn" onclick="validation_form()"> <p style="margin: 0;">Отправить</p> </div> </form> <div id="feedback-message"> <img src="../assets/img/success-icon.png" alt="success"> <div class="text-message"> <p class="green-text">Сообщение успешно отправлено!</p> <p>Спасибо за Ваше обращение.</p> </div> <button class="ok-btn"> <p class="green-text">Ок</p> </button> </div> </div>
$(this).click()
- Grundy