Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to display comment form validation errors (as well as captcha error) on the comment form itself and not on a different page. How can I do that?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

This question have answered again, here

Also you can do the same with JQuery and Validation plugin

share|improve this answer
    
Used the jquery with some extra configuration and captcha adjustments –  hannit cohen Jan 27 '11 at 2:40

I was facing same problem and was searching for solution i found the solution

Open your function.php file and past below code:

    function comment_validation_init() {
    if(is_single() && comments_open() ) { ?>        
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
    <script type="text/javascript">
    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: "Please fill the required field"
    },

    errorElement: "div",
    errorPlacement: function(error, element) {
      element.after(error);
    }

    });
    });
    </script>
    <?php
    }
    }
    add_action('wp_footer', 'comment_validation_init');

For giving style:

.error  { padding: 10px 0 20px 0; color: #FF0000; }
input.error, textarea.error { color:#000000; }
share|improve this answer
1  
Please add an explanation. What does your code exactly? And never use the wrong jQuery version, always enqueue the built-in jQuery. –  toscho Jan 31 at 7:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.