WordPress Plugin: Comment Validation
Ever got annoyed when submitting a comment on a wordpress blog and just getting a blank page with a error message like “please fill out required fields” and nothing else? This plugin aims to help by adding validation to the comment form. When a user submits the form and something is missing, an appropiate message is displayed and individual fields are highlighted. When the email or url is in an incorrect format, a message is displayed accordingly.
Why should you install it? Because you care for comments and want to help users reduce mistakes that hold them off from commenting at all.
Whats the technology used? jQuery (bundled with WordPress) and the jQuery Validation plugin with a few customizations to make it fit into the standard WordPress theme.
Is it compatible with other plugins? The plugin is tested with the Draw Comments plugin and works, though the performance is slightly degraded. Other plugins haven’t yet been tested, though it now uses the wp_enqueue_script functions for the script includes, ensuring proper dependency loading.
Download WordPress-Comment-Validation-Plugin (zip)
Installation:
Download the plugin, extract it to your wp-content/plugins directory and activate it just like any other wordpress plugin (admin panel/Plugins). That’s it!



Pretend for a moment that I do not have a clue as to what you are talking about.
Sounds interesting, but I am getting rather tired of plugin developers who totally fail to explain what their plugin does in clear English. So, I am going to pass.
[Reply]
hi. Thanks for plugin
perfect.
Regards
[Reply]
@John: I’ve updated the description. Is that better?
[Reply]
interesting
[Reply]
Just wanted to see the all the fuz is about =)
[Reply]
Will it work with the Draw Comments Plugin for WP ?
Thanks …
[Reply]
Michael Reply:
August 19th, 2012 at 08:20
Thanks
[Reply]
@Dr-Hack: Just commited an update to improve the performance when used together with Draw Comments. It worked already but tried to validate all the hidden input elements, which was rather slow. They are now ignored.
[Reply]
Nice plugin, thank you. It’s a posibillity to make it work with Math Comment Spam Protection as well?
[Reply]
Thanks! The description is much better. And, the plugin is now worth trying out.
[Reply]
i just installed it and it seems interesting
nice plugin mate and new description is much better and explanative
[Reply]
@Buddha: I’ve tried out that Math Comment Spam Protection and it didn’t work for me, throw some error about wrong arguments for array-rand. Not to keen to debug some random plugin.
@John: You’re welcome.
[Reply]
now this is pretty dam cool if I do say so myself, thanks guys.
[Reply]
nice, thank you
[Reply]
Doesn’t seem to be working aat all on 2.71
[Reply]
the same thing here
doesn’t seem to be working aat all on WP 2.71
[Reply]
I am trying to use your Comment Validation Plugin on a form that is displayed on a shadowbox (Fancybox Plugin). When you click the submit button the form will refresh the page without performing the validation. Do you have any experience with this problem?
[Reply]
@underclass and @doron: I’ve updated the wordpress plugin to use the latest version of the validation plugin and tested with 2.7.1.
[Reply]
Thanks for this great plugin! Really good work.
[Reply]
Works fine on my 2.7.1, no admin screen though :S
[Reply]
@Marc: What admin screen? There is no configuration for the plugin, therefore no need for an admin screen. Or is there anything you’d like to configure?
[Reply]
I cannot for the life of me get this to work. I’m using 2.7.1 and no crazy plugins that I can imagine would conflict with this (Events, Google Analytics, Google Sitemaps, Askimet). I’m using the WP Framework theme that I customized for design and not much more.
My pages are pulling the .css & .js files into the head and my source code structure looks almost the same as this form. I click submit on an empty form and get the WP default page….
What am I missing??
[Reply]
@Dappy: It looks like jQuery is loaded twice on your site, once elsewhere and once by the comment validation plugin. Try to remove one of the includes.
[Reply]
I finally got it to work. You might want to add to your description:
The form tag MUST have an id of #commentform or else it won’t work even if the commentvalidation.js and .css files are edited.
Mine was #comment-form to follow my coding method and the syntax WP Framework had been using. I actually think WP framework made that change.
- Thanks, Dappy
[Reply]
Is there a way to customise the error message:
>> Please enter a valid email address.
and also add a “Please enter you name” one
[Reply]
dankeee
[Reply]
Works fine on my 2.8.4, no admin screen though. Thanks
[Reply]
I want the error messages to be displayed under the particular input element, i.e. if the error is in email field then it just shows under email field only, so as to make it even better user experience.
Any solutions for that?
Thanks in advance…
[Reply]
Seems to be a stray
in the comment-validation.php file (/wp-content/plugins/comment-validation/comment-validation.css">). Other than that this works great.[Reply]
Stray
</script>– got stripped out in my last comment.[Reply]
Very useful.
Thanks a lot.
[Reply]
I have to make a remark to that first comment on your page and am sorry! People need to be alittle more appreciative to people like you who help us the people learning. I more than well appreciate the time spent by others, so that I can grow and become better. If more people showed graditude instead of negativity, the world might be different. Thankyou for your time given to us.
[Reply]
Nice plugin, works great with my site. But since the JS files are packed, I can’t translate the error messages. Could you make this possible? Thanks!
[Reply]
@Ed and Ralph: Take a look at the jQuery validation plugin (also on this site). Thats whats used by the WordPress plugin. You can customize messages, even without modifying the packed file, by overwriting some JavaScript variables in your own script, included after the other files.
For example, to set a different message for a required field:
@iklan: There is no admin screen, yet.
[Reply]
Thanks, works perfect!
For the people who also want to translate the error messages:
Open the comment-validation.js file:
Translate the error message at the 2nd line (between the DIVs).
And find:
$.validator.messages.email = “» ” + $.validator.messages.email;
$.validator.messages.url = “» ” + $.validator.messages.url;
And translate as follows:
$.validator.messages.email = “» EMAIL ERROR IN YOUR LANGUAGE”;
$.validator.messages.url = “» URL ERROR IN YOUR LANGUAGE”;
That’s it! Thanks again!
[Reply]
I’ve got 1 question remaining:
Is it possible to get the plugin to validate extra comment form fields?
I’m asking this because I’ve some radio buttons, which should be required when filling in the comment form.
[Reply]
@Ralph: You can add that in the comment-validation.js file, too. Just specify additional rules. Details can be found in the Validation Plugin documentation.
[Reply]
Thanks for the quick reply, Jörn!
I’m sorry for not explaining myself properly right from the start. The thing is that adding an extra rule does indeed validate a normal radio button.
At first I didn’t think this wasn’t the case, but after your advise I looked at it again and found out that it did work. The problem is that I want to validate jQuery Star Rating Plugin:
http://www.fyneworks.com/jquery/star-rating/#tab-Overview
This plugin turns radio buttons into stars. Despite the fact that the radio buttons are still in the source, the validator ignores them as soon as they’re being displayed as stars.
Do you think this can be solved somehow?
[Reply]
I solved the problem of the star rater not being validated as follows:
The value of the star rater is now being passed to a hidded field in the form.
Validator plugin then validates the hidden field.
Works perfect! Thanks again!
[Reply]
works perfect
[Reply]
This plugin is loading Javascript incorrectly. You need to use the built in wp_enqueue_script functions, because loading jQuery separately can mess up JavaScript loaded by other plugins.
[Reply]
@Dan: Thanks for the info. I’ll look into it.
[Reply]
After installing this plugin and activating it, it broke the Lightroom 2 plugin.
The Lightroom 2 plugin no longer works at all.
When an image is clicked on, it goes to the image URL instead of opening it with Lightroom 2.
[Reply]
Great plugin!!
to John Gohde: please shut the fuck up! and respect the architect!!!!!
You have to be pleased that some people can even try to speak english. ’cause i’m sure that without english you belong to the Trash.
[Reply]
Seems to be a problem when validating the URL field.
http://www.google.com — FAILS
google.com — FAILS
http://google.com — WINS
http://www.google.com — WINS
This could be a problem for users when entering their URL. Any chance you can take a look and maybe offer up an updated file?
Cheers,
Dave
[Reply]
svenja Reply:
June 6th, 2012 at 18:13
Hi,
is there a solution for this bug?
I got the same problem.
Thanks a lot.
Bye,
Svenja
[Reply]
you have a big error in comment-validation.php on line 15
echo ‘/wp-content/plugins/comment-validation/comment-validation.css”>’;
should be
echo ‘/wp-content/plugins/comment-validation/comment-validation.css” />’;
since you are closing the link tag, not a script one.
[Reply]
Thanks for this. I’m building a site using 2.9.1 from the ground up and it worked for me. Saved me a lot of work but could not get it to validate. Following info from the validation site I was guided to this piece of code in the comment-validation.php.
echo ”;
The closing tag ‘script’ should not be there. I removed it and closed the ‘link’ tag and it validates fine.
It now looks like this:
echo ”;
Thanks again
[Reply]
Sorry, new to this and didn’t know that I couldn’t post code. The extra ‘script’ tag came after
comment-validation.css
[Reply]
this is perfect. FINALLY a plugin that worked for me. thank you very much.
[Reply]
hi jörn,
i use the plugin wp-e-commerce and as soon as i activate your plugin the lightbox effect on my productpage (images) does not work anymore. when you click on an image it goes to the image url…
is there a way to fix it?
[Reply]
Thanks for the plugin! I´ve finally found it.
Thats what i was looking for.
Kind regards!!
[Reply]
I just want to thank you so much for this plugin! It is so simple yet so functional. I had it up and running and lightly customized in less than two minutes. Many, many thanks!
[Reply]
Thanks for this plugin.
[Reply]
It would be great to have this type of functionality for the WordPress signup form. Any chance of a plugin for that? Or some direction on how to proceed based on your work on the Comment Validation plugin?
Thanks!
[Reply]
@Mike: Take a look at the source for this plugin, its pretty simple. That should be a good starting point.
[Reply]
I like this, it’s very useful.
Can it be made to handle errors in a way more similar to the jQuery Validation Plugin Demo – where text is placed below the appropriate field(s)?
[Reply]
Well .. Thankx a ton for this great plugin , it will really help in preventing the hundreds of SPAM comments on our WP blogs. it is really helpful..
Thanks again..!!!…
[Reply]
I was in a severe need of such plugin now i will use it in my blog. I hope it will really help me to control the unwanted comments. Thanks a lot…
[Reply]