For Magento 1.9 Product page, In custom option- text field, I try to list out the number of character for user-input on the text field, but with no success.

  • Thanks. But what i want is a text-counter that help user to know how many characters they have input. – pakicle Jan 27 '15 at 6:19
  • 3
    I'm voting to close this question as off-topic because this is not related to magento. It seems to be a question regarding javascript/jquery. You can try stackoverflow for this. – Rajeev K Tomy Jan 27 '15 at 7:20

You can do this using jquery, please refer to below fiddle

    $('#mytextbox').keyup(function() {
    var cs = $(this).val().length;


Event.observe(window, 'load', function() {
Element.insert( $('name').up().next().down('span'), { 
    'after': "<div id='name_counter'>Char count: <span id='name_counter_num'>"+(30-$('name').getValue().length)+"</span></div>"
 Event.observe('name', 'keyup', function(event) {  
    $counter = 30-$('name').getValue().length;

}); Magento uses prototype.js by default so i am providing a code in prototype's format

Not the answer you're looking for? Browse other questions tagged or ask your own question.