Limiting the characters in the customer comment box on the checkout page

Hi,

Is it possible to limit the number of characters on the checkout page’s customer comment box?

I can see at present it is set to 200 characters:

<input class="textbox maxwidth" type="text" size="20" maxlength="200" name="checkout[comment]" value="" id="checkout_comment">

We’d like to limit it to 30 characters.

Thanks,
Dan.

Hi Dan,

You could add this code to your Footer template:

{if (pageproperty[‘pageid’] eq ‘checkoutstep2’)}
<script>
$(‘#checkout_comment’).attr(‘maxlength’, 30);
</script>
{endIf}
If you’re not comfortable adding it yourself, we can add it for you.

Regards,
Donogh

Hi Donogh,

That worked a treat.

If you can edit your post or if anyone else wanting to use the above remember to add in {endIf} to close the if statement.

Thanks for your help.

1 Like

Hi Dan,

I’ve updated that - good spot!

Regards,
Brendan

1 Like

For others reading, you can use a similar method to substitute the input box to a multi-line text-area which might prove a little more user friendly for customers wishing to leave detailed order notes.

{if ( (pageproperty[‘pageid’] eq ‘checkoutstep2’) )}

<script type="text/javascript">
$('#checkout_comment').replaceWith('<textarea cols="80" rows="3" name="checkout[comment]" value="" maxlength="200" id="checkout_comment"></textarea>');
</script>

{endIf}

2 Likes