Add code in your theme function.php file
function comment_validation_init() {
if(is_single() && comments_open() ) { ?>
jQuery(document).ready(function($) {
$(‘#commentform’).validate({
rules: {
author: {
required: true,
minlength: 2
},
email: {
required: true,
email: true
},
comment: {
required: true,
minlength: 20
}
},
messages: {
author: "Please fill the required field",
email: "Please enter a valid email address.",
comment: "Comments required minimum 20 characters."
},
errorElement: "div",
errorPlacement: function(error, element) {
element.after(error);
}
});
});
</script>
<?php
}
}
add_action('wp_footer', 'comment_validation_init');
Related Posts:
- Order posts (across the whole site) by metadata date
- Sort posts by Date (DESC) and by Title (ASC)
- Filter the query ONLY for the search results page
- How do I change parameters without changing the core
- Comments to only be seen by their author
- Is it good practice to use wpdb->query() function?
- exclude a category from a search on a specific page
- example of build_query function?
- Shortcode pagination not advancing
- Change the HTML of the comment form that is generating somewhere from the core WordPress
- Create a new query in function.php to filter blog posts
- Connecting to a 2nd DB gives me no results when querying
- How to ignore posts in pre_get_posts?
- get_terms (or tax_query) for term of current post?
- shorthand syntax for custom fields
- Using One Function To Create Two Different Shortcodes
- How do I make the comment disappear after deleting from the database?
- Delete oldest wordpress post (SQL query)
- Selecting specific query for offset
- Shortcode with pagination advancing multiple queries
- Comment function for page
- How can I return the result of my custom function?
- Function returning queried meta value based on current post ID
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- Undo a function that is not (seemingly) hooked to an action?
- Sorting date results from a query
- Getting full code of wp_list_comments instead of replacing it
- Why use if function_exists?
- Use AJAX in shortcode
- Include files in child theme functions file
- WordPress Theme Update Action?
- How to get woocommerce inventory status [closed]
- Does WordPress Development Mode Exist (with not minified JS)?
- WP_Query in functions.php
- Implementing DNS Prefetching with WordPress
- Organize functions.php
- Why do I get Fatal error: Call to undefined function get_most_recent_post_of_user()?
- Edit the_content function
- write in functions.php
- get excerpt without images
- display 100 products per page on product category page [closed]
- Checked() showing up twice in custom fields
- Gravity Forms field entries into wp_query loop [closed]
- Global functions on WPMU
- Remove the deleted users avatar from list
- Update Content based on expiration time or queued processing
- Adding to fontawesome-webfont.woff2 to boost website speed
- How to enable template page only for a post id page
- set_post_thumbnail when user is not logged in
- Remove after images
- Get First Child Page ID or Permalink in WordPress Admin
- Footer disappears when using the_content ( )
- Passing User_Fields to Contact form 7 [duplicate]
- How can this crude function be improved?
- How to override woocommerce.css?
- Including php files within template
- Author Date Function not working as expected [duplicate]
- Add_filter when value is no variable?
- The Loop not looping?
- wp_star_rating() – Adding a 5 star rating system to theme
- Use Composer Package inside class – Namespacing error
- Default Nav Highlight
- Update to functions.php not showing in dashboard
- Unable to point the child theme directory even using get_stylesheet_directory()
- Change WooCommerce add_to_cart Button Text?
- WordPress Website with Login system
- Return link pages instead of displaying them
- Adding Read More to Custom excerpts
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- Add custom taxonomy using JS in post editor
- WordPress: Highlight search result exact matches
- Adding custom social icons to the social media icon block in the Gutenberg editor?
- Allow user select role in wordpress default registration without plugin
- search and replace using regex
- post value to function with Ajax and jQuery
- is_product_category(‘Services’) not working
- How to automatically add counted number to navigation menu items?
- Replace theme function
- How to access custom class methods from any include without using global
- Insert Modal on user first login
- I want to change the WordPress comments file
- What is best practices to move the following code into a function?
- Correct way of Enqueue self hosted fonts in sass project
- function syntax is off,
- Change category checkbox into radio button [duplicate]
- wp_enqueue_script only works outside of action
- How can I include user meta information in the resulting array of a WP_User_Query?
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Show the online status of the current post’s author
- Get Value of Custom Field
- How does child theme functions.php work with parent theme functions.php? Is it like CSS? [duplicate]
- restrict access to specific urls on a specific period of time
- Need a functions that adds (adm)/(mod) if current user is admin/moderator right after their username
- Add title & subtitle to shortcodes
- How to Delete Posts by title?
- clickable title of 2 post on mainpage USING functions.php
- Display function from functions.php in tag.php
- AJAX values converted to PHP Variables?
- Custom Post Type Search
- woocommerce_sort_product_tabs() expects an array