How to limit the characters number in products comments?

  • Posts: 224
  • Thank you received: 8
5 years 10 months ago #292977

I can't find any configuration do do this... is this something that can be done maybe editing the db tables?
(I remembere reading a very old forum ropic saying this, but I can't find it again now)

Thank you!

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
5 years 10 months ago #293000

Hi,

Yes. You can change the type of the vote_comment column of the hikashop_vote table to for example "varchar" with the number of characters you want (up to 256). I've never tried but it should do it.
If that doesn't work, then it would require some javascript on the view file displaying the comment form to handle the number of characters limitation.

Please Log in or Create an account to join the conversation.

  • Posts: 224
  • Thank you received: 8
5 years 10 months ago #293023

Ok thanks!
I found this code suggestion, really simple to apply, I paste it below in case someone else need it.

insert this at the top of vote/ form.php view

<script>
function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}
</script>
insert this into the textarea (change 500 to your wanted maximum characters)
onKeyDown="limitText(this,500);" onKeyUp="limitText(this,500);"

the whole textarea should look like this
<textarea type="text" name="hikashop_vote_comment" id="hikashop_vote_comment" class="hikashop_comment_textarea" placeholder="<?php echo JText::_('HIKASHOP_POST_COMMENT');?>" onKeyDown="limitText(this,500);" 
onKeyUp="limitText(this,500);"></textarea>

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum