I have a simple HTML5 form that I want to use for the required field validation. My problem is that I want to use HTML5 form validation, but at the same time avoid the actual form submission, because instead I want to make a jQuery ajax call. I know that you can disable html5 validation, but I want to keep this as the main form validation method instead of the jQuery plugin.
Any thoughts?
HTML
<form action="donothing" id="membershipform" method="get" accept-charset="utf-8"> <input type="text" class="borderr3 innershadow3" name="some_name" value="" id="some_name" placeholder="first and last name" required> <input type="email" class="borderr3 innershadow3" name="some_name" value="" id="some_name" placeholder="email" required> <input type="phone" class="borderr3 innershadow3" name="some_name" value="" id="some_name" placeholder="phone" required> <input type="phone" class="borderr3 innershadow3" name="some_name" value="" id="some_name" placeholder="mailing address" required> <input type="phone" class="borderr3 innershadow3" name="some_name" value="" id="some_name" placeholder="how you heard about us" required> <p> <input type="submit" id="submitbtn" class="submitbtn" value="Continue" style="width:265px"> </p> </form>
JAVASCRIPT:
$(function(){ $("#submitbtn").click(function(){ $.ajax({ url: "<?php bloginfo('template_url') ?>/ajax-membership.php", success: function(txt){ if(txt){ $("#thankyou").slideDown("slow"); } } }); }); });
jquery html5 forms
Rees Apr 16 2018-11-11T00: 00Z
source share