WordPress.org

Ready to get started?Download WordPress

Forums

Ad a check box for terms and conditions for comments (7 posts)

  1. bencurious
    Member
    Posted 5 years ago #

    I have searched everywhere. I would like to ad a check box saying I have read the terms and conditions under the Comments that people will have to check before they can post.I have found plugins that just add terms and conditions under the comments but I would like them to have to check a box before a post can be made.

    Any ideas or know of something i can use?

    Cheers!

    Ben

  2. Mark / t31os
    Moderator
    Posted 5 years ago #

    Something like this would work, and it's a very simple script.

    http://lab.artlung.com/validate-checkbox/

    Does that help?

  3. bencurious
    Member
    Posted 5 years ago #

    Hi that looks like it should work, although I am not sure how to apply this to my php file for the comments in my wordpress...?

  4. Mark / t31os
    Moderator
    Posted 5 years ago #

    You just need to change the target's name...

    Take this example element.

    <input type="CHECKBOX" name="CHECKBOX_1" value="This...">

    In this case the target name is CHECKBOX_1 which is then reflected in the Javascript.

    You just need to find out the name (name="example") for your checkbox and update the Javascript to reflect that.

    You'll need to place the Javascript in between the <head> tags in your header.php

    Here's an example (you'd need to change where i've put "NAME-HERE")

    <script type="text/javascript" language="JavaScript">
    <!--
    function checkCheckBoxes(theForm) {
    	if (
    	theForm.NAME-HERE.checked == false)
    	{
    		alert ('You didn\'t choose any of the checkboxes!');
    		return false;
    	} else {
    		return true;
    	}
    }
    //-->
    </script>

    And also add onsubmit="return checkCheckBoxes(this);" onto the comments form.. (comments.php in your theme - same file you've proberly added your checkbox to).

    It's untested, but it should be that easy (i can't see why not)....

    :)

  5. bencurious
    Member
    Posted 5 years ago #

    Thank you so much for your reply! It took me a little while to get it sorted because I forgot to put onsubmit="return checkCheckBoxes(this);" in the comments form! But now it is working a dream! :) :)

    I hope other people find this post and use the info in it! Thanks a lot t31os_

    Ben

  6. Mark / t31os
    Moderator
    Posted 5 years ago #

    You're welcome.. :)

  7. bencurious
    Member
    Posted 5 years ago #

    http://www.koha.biz/wordpress/ check out an article too see :) Site still work in progress

Topic Closed

This topic has been closed to new replies.

About this Topic