You can mimic the default jQuery plugin behaviour as follows:
Test if the form
is valid; if not prevent the default action from occurring using preventDefault()
:
$(document) .on('click', 'form button[type=submit]', function(e) { var isValid = $(e.target).parents('form').isValid(); if(!isValid) { e.preventDefault(); //prevent the default action } });
EDIT: this comes in handy if you want to fine-tune your validation test i.e. validating some controls conditionally.
Related Posts:
- jQuery Form Validation before Ajax submit
- Clear form fields with jQuery
- Get a form action/url with jquery
- Twitter Bootstrap Modal Form Submit
- WordPress AJAX File Upload – FrontEnd
- jQuery and AJAX Not working with Select Form Element
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Registration e-mail check with AJAX
- jQuery Validate wp_editor
- Gravity Forms not loading under https, jQuery is not defined
- Gravity list field override and adding javascript [closed]
- How do I setup nested repeatable option fields?
- Accept AJAX call with serialized form data
- Making the wordpress login form a jQuery dropdown
- Cannot prefill hidden Ninja Forms fields
- Frontend Post with JQuery AJAX to Php Issue
- Ajax form submit not working, returns 0
- jQuery will not work on page from snippet or file
- JQuery Counter Limit not working for WP Comment Textarea
- Required radio button does not validate in form, when clicked through Javascript/jQuery
- Duplicate “default” form with jQuery
- Converting a working AJAX form to work with WordPress
- jQuery forms & updating info
- How to setup multi-page using jquery?
- Is textarea always accesible throught textarea#content in wordpress dashboard for a specific page?
- Auto next upon clicking image without clicking Next button
- jQuery Validation plugin and Bootstrap 4 CSS classes
- Form validation before submitting
- Is not using admin-ajax to ajax submissions okay?
- $_POST empty in using new php file added to theme
- value not saving in the form when dynamically creating an input
- Customize wp-admin form custom fields
- Auto Select Child categories on Multiple Dropdown – Jquery
- Adding jQuery timepicker to contact form
- jQuery form plugin, submit in the wordpress way
- jQuery Live Form Validation in WordPress
- Contact Form 7 checkbox to add a new class to a div [closed]
- jQuery color picker function on change
- Elementor form – checkboxes validation
- How to send multiple data fields via Ajax?
- Adding an onclick function to go to url in JavaScript?
- Checking a Url in Jquery/Javascript
- Download File Using jQuery
- Jquery Ajax Posting JSON to webservice
- laravel updateOrCreate method
- How can I display a tooltip message on hover using jQuery?
- Split string in jquery
- Comparing dates in jquery
- jQuery: using a variable as a selector [duplicate]
- Slide right to left?
- How do I make script load after jquery?
- Best Practices for Seperating jQuery from HTML/PHP
- Add custom shortcode button to Editor
- Why do we include jQuery in the header?
- Display admin_notice error message form jQuery event
- Unbind postbox click handler
- Querystring data gets truncated
- Displaying custom post-types in a Fancybox div and then linking to them
- wp_enqueue_script and wp_register_script in theme not working
- How to Use JSON With AJAX?
- wp_localize_script, variable is not defined in jquery
- Hide/show customizer controls based on other settings in Customizer
- When does WordPress automatically enqueue jQuery?
- How to get those data using with ajax json?
- SmoothScroll not working in WordPress
- SSL issues with WordPress site
- Limit filetype and wp media
- Good Solution for Adding jQuery Tabs Anywhere Within WordPress?
- Problem getting .js file to load via a plugin
- Using jquery-1.7.2.min.js instead of the wordpress jquery
- Adding jQuery UI elements to WordPress page
- Jquery UI Google CSS, from where?
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- jQuery selectable() function won’t work in wordpress
- jQuery(selector) vs. $(selector)
- Null/undefined return in WordPress AJAX request
- How do I make Contact Form 7 pop up in thickbox? [closed]
- jQuery .load and WP function
- Determine image height within Fancybox
- How to display contact form 7 form in vanilla js without jquery in frontend
- How can I get this menu container to be the height of the contents?
- JQuery is not working after complete load of the page
- Carousel Slider For Custom PHP Snippet Is Not Working
- why does so many javascript libraries are loaded along with my website?
- Why does my media selection script write to ONLY the first input field?
- Modify the href attribute of tag dynamically in WordPress
- Move jQuery on *top* of footer
- Call admin ajax using absolute url? Relative URL breaks (frontend ajax)
- Responsive framework – edit child js
- Page keeps refreshing with Ajax form
- jquery issue in functions.php
- JS plugin script loading but not working
- WP Calendar Shortcode not working on my theme
- change the icon of a custom post type in WordPress to use twitter boostrap
- Ajax request with jQuery without WP_ajax
- JS file not loading [closed]
- How can insert JQuery in WordPress? [closed]
- I need a Pop up with description when i click an image
- Fire an event after Featured Image selection
- How to add input file plain text and submit to publish?