Skip navigation
Currently Being Moderated

Making the comment fields mandatory

Jul 17, 2012 1:27 AM

Hey BC community,

 

Have any of you had a client request that the comment fields be mandatory? I know they're subject to content approval but it has been requested.

 

Any help would be appreciated,


Cheers,

 

Pat

 
Replies
  • Currently Being Moderated
    Jul 17, 2012 5:49 AM   in reply to pat macy

    Hi Pat,

    by comments do you mean as on a blog article?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 17, 2012 10:33 AM   in reply to Graphite Web

    Hello Pat,

     

    The comments form uses the same validation as any other form. You just need to add the if statement for the correct field you want to be required.

     

    So for the full name input text field you would add this:

     

    • if (theForm.fullname) why += isEmpty(theForm.fullname.value, "Full Name");

     

    Then for the email address:

     

    • if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);

     

    Add these on top of the captcha validation, and keep it just like any other form. You can clean up the validation code with http://jsbeautifier.org/

     

    Here is an example:

     

    http://bcg-sandbox.hotpressplatform.com/_blog/Blog/post/nope_this_one_ is/

     

    Hope this helps,

    Chad Smith | http://bcgurus.com/Business-Catalyst-Templates for only $7

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2013 12:28 PM   in reply to Chad - BCGurus.com

    Hi Chad, please assuming it is the feedback multiline field of the comment form I want to validate. How would the validation go?  I have tried using the full name syntax you showed above, but it doesn't validate. Please help. Regards

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2013 12:50 PM   in reply to topelovely

    Hello topelovely,

    Not sure why it did not work for you, it is the same code as the fullname field. I've tested this on my sandbox site and this should be the code you need to add to your validation:

     

    if (theForm.Feedback) why += isEmpty(theForm.Feedback.value, "feedback");

     

    I've placed this under the email validation. You can change the "feedback" to say what you want, not when the user doesn't add any feedback the validation pop up says "Please enter feedback".

     

    If this still does not work please post a link or your code and we can go from there. But I hope this works for you =0).

     

    Thanks,

    Chad Smith - BC Gurus

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points