There is this form
<form method="post"> <input type="text" placeholder="Your name" autofocus required pattern="[az]{1,15}"/> <input type="text" placeholder="Phone-number" required pattern="[0-9]{6,15}"/> <input type="email" placeholder="Email" required/> <input class="button" type="submit" rel="reg_form" value="request call"/> </form>
so i implemented Pop-up
<div class="popup reg_form"> <span class="home"></span> <p class="popup_p">Request sent!</p> <p>We will call you as soon as we can.</p> <a class="close" href="#">Close</a> <button class="close">Close</button> </div> $(function () { $('input.button').click(function () { $('div.'+$(this).attr("rel")).fadeIn(500); $("body").append("<div id='overlay'></div>"); $('#overlay').show().css({'filter' : 'alpha(opacity=80)'}); return false; }); $('a.close').click(function () { $(this).parent().fadeOut(100); $('#overlay').remove('#overlay'); return false; }); $('button.close').click(function () { $(this).parent().fadeOut(100); $('#overlay').remove('#overlay'); return false; }); });
but it appears as soon as I click on submit
, but when I click, it will be validated, and if all the fields are completed successfully, it will send the form and show pop-up
. How to do this?