Here is a resource that you can edit and use Download the source code or see the demo here. http://purpledesign.in/blog/pop-out-a-form-using-jquery-and-javascript/
Add a button or link to your page as follows
<p><a href="#inline">click to open</a></p>
"# inline" here should be the "id" of the one that will contain the form.
<div id="inline"> <h2>Send us a Message</h2> <form id="contact" name="contact" action="#" method="post"> <label for="email">Your E-mail</label> <input type="email" id="email" name="email" class="txt"> <br> <label for="msg">Enter a Message</label> <textarea id="msg" name="msg" class="txtarea"></textarea> <button id="send">Send E-mail</button> </form> </div>
Include these scripts to listen for the click event. If you have an action defined in your form, you can use the "preventDefault ()" method
<script type="text/javascript"> $(document).ready(function() { $(".modalbox").fancybox(); $("#contact").submit(function() { return false; }); $("#send").on("click", function(){ var emailval = $("#email").val(); var msgval = $("#msg").val(); var msglen = msgval.length; var mailvalid = validateEmail(emailval); if(mailvalid == false) { $("#email").addClass("error"); } else if(mailvalid == true){ $("#email").removeClass("error"); } if(msglen < 4) { $("#msg").addClass("error"); } else if(msglen >= 4){ $("#msg").removeClass("error"); } if(mailvalid == true && msglen >= 4) { </script>
You can add everything you want to do to your PHP file.
source share