Every post / page / post type is wrapped around a universal form with the ID of #post
. So if you want to validate a page before submitting it you just need to say something like:
jQuery(document).ready(function($){
$('#post').submit(function(){
// Validate Stuff
return false;
});
});
Then you’ll want to actually enqueue your javascript – View Codex
function my_enqueue($hook) {
if ( 'edit.php' != $hook ) {
return;
}
wp_enqueue_script( 'my_custom_script', plugin_dir_url( __FILE__ ) . 'myscript.js' );
}
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
As far as your concern that another on submit handler will cancel out yours, from what I’ve tested it doesn’t matter how many submit handlers return true, if 1 is false, the form will not submit.
Related Posts:
- How can I log a user out of WordPress before the page loads?
- Filter or action hook to insert content on admin pages before tag
- Remove 3rd party plugin notices from within own plugin
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How can I see all the actions attached to an “add_action” hook?
- How to include code only on specific pages?
- Changing the “Plugin Activated” Message Default
- How to only hook on Single.php after content?
- When can you get current page ID and initialize hooks right after?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- How do I only load a plugin js on it’s settings pages?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Use external link in the add sub menu
- do_action and hook methods
- Is it possible to add an action to the currently running action?
- Is there an action that is called when a post is restored from the trash?
- How to filter content post only on save
- Is it possible to remove this action? (as it’s added just before it’s called)
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- Can I use a method from an existing plugin as an action hook?
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Where to hook my plugin’s action
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WordPress filter that hook after each action/filter hook
- Any hook for pre-plugin-update -either bulk or single plugin update
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Insert new user with form submit ‘init’ hook
- How to get all of the activate_plugin action parameters?
- Calling plugin function inside custom plugin for onclick event
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- do_action() hook into load-(page)
- How to get post ID with hooks publish_post, new_to_publish, etc
- edit_user_profile and show_user_profile are not firing inside a class
- Add sub menu page in your plugin
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- Deactivate JS Script in Plugin Shortcode
- Create a post builder skin in a plugin
- remove_action not removing add_action from constructor
- Plugin Development – Functions or Hooks?
- How to get menu location in wp_update_nav_menu hook
- Hook for page Request?
- Are there action hooks for comments?
- WooCommerce: after install hook
- How to remove a class function from a plugin by using remove_action()?
- Advanced WordPress plugin activation detection
- Add action to custom Function
- What hook can I use to modify custom post data before it is displayed on the page?
- How to hook into action/filter call
- Hook from plugin doesn’t fire up from external PHP script
- update_option_{$option} not working (do function after options are saved)
- Callback hooked to post_updated firing on new posts as well
- The function called on the wp head hook becomes null
- Hooking into the HTML header container
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- {status}_{post_type} does not run correctly?
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- wp_login_form() ignoring login_form action hook
- Admin page and admin menu. Permissions plugin
- Passing a parameter to filter and action functions
- Run only on plug-in activation instead of wp_head
- Plugin Hook: Get posts
- change output location of plugin function using a custom hook
- OOP Plugin: Where should I place the action hooks in the class?
- add query string to all pages after user logged in
- How wordpress plugin hooks works? [duplicate]
- Hook automatic_updates_complete to autoupdate plugin
- WordPress Action Hook inside Classes
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- Access post title from custom meta box on title change
- How to use filter to disable adding a product to wishlist?
- Save user total active time after login in wordpress [closed]
- in source code but I can’t find it in files or plugins
- WordPress: Add custom add_filter for custom functions
- Updating WordPress plugin admin panel footer text
- Background Music WP [closed]
- WordPress permissions error with admin account
- Trying to add_action in a loop
- how to execute some code after a post is published in WordPress [duplicate]
- getting notifications about updates only in the “core” page
- profile_update hook doesn’t works inside a class
- wp_loaded with static Singleton
- How to use custom Javascript code inside a plugin?
- wp_trash_post hook – problem with page updating if using wp_die
- How to remove products-links after the product title using remove_action