Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Set Gift Message Limit to 300 Characters. 
Total Posts:  33
Joined:  2008-11-14
Delhi, India

I recently had an requirement to limit the gift message to 300 characters. As the gift message is filled in a text area hence we need to use a small JavaScript code in order to implement this limit.

Please find an attached file named inline.phtml which needed to be placed at


All the code required is inside this file.

This file will display a message to the user if he exceeds 300 characters limit and even reduce the charters entered by him to below 300.

I made changed in this script for Magento version 1.1.8

Any questions then let me know

Anshumaan Bakshi

File Attachments
inline.phtml  (File Size: 18KB - Downloads: 164)
Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  43
Joined:  2007-09-11
Los Angeles, CA

For anyone interested in using this character limit notification in more recent versions of Magento, it\’s a simple matter of adding a copy of inline.phtml to your theme\’s directory and then editing it as noted below.

Copy from inline.phtml from magento\\app\\design\\frontend\\base\\default\\template\\giftmessage\\inline.phtml to

Then, with that copied version of inline.phtml, edit the code (around line 60 in v1.4.1.1) that reads:

if(!$(source).value.blank()) {

to read

if($(source).value.length 300)
'Please limit your message to 300 characters\');

NOTE: Pay special attention to instances of “{” as the code in the original file has a “{” at the end of the first line and, if it’s left in, it will cause things to not work as expected.

This is the same code used in AnshumaanBakshi\’s code above, except that I\’ve corrected the spelling of \"characters\" in the alert message.

If you want to use a number of characters other than 300, simply edit the 3 instances of \’300\’ in the code above to represent the number you wish to use.

A nice side feature of this code is that it notifies the customer to limit the message to 300 characters, then automatically truncates the existing message down to 300 characters. Naturally, it would be great to have a more robust system (that counts down how many characters are left/available within a message field); but this is a good simple fix when character limits are needed on gift message fields.


Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top