Jump to content


What is the best way to add keyup function to codeigniter form_textarea?

  • Please log in to reply
2 replies to this topic

#1 RalphLeMouf

  • Members
  • PipPipPip
  • Advanced Member
  • 153 posts

Posted 08 January 2013 - 07:23 PM

Hello -

I am trying to add a counter that starts with the maximum number of characters a lotted and counts backwards as the user types until they reach their limit. I'm assuming the best way to do this is with jquery keyup, however I have tried A BUNCH of different snippets of jquery and I am not able to integrate it within the codeigniter format. What is the best way to do this with codeiginter?

Here is my I am trying to add it to. I would prefer to leave my structure as is and just add what is needed.

<div class="edit_section_title">
My Life <br />Tell us a about yourself <span class="edit_sub_text">(1350 character limit)</span>
<div class="edit_text_area"> 

echo form_textarea('mylife');
echo form_textarea('mylife', $user['mylife']);


thanks so much in advance

#2 cpd

  • Members
  • PipPipPip
  • ¬_¬
  • 892 posts
  • LocationLondon, UK

Posted 08 January 2013 - 07:58 PM

Create a Javascript file and include it in the header. The file should contain the logic for adjusting the character counter - possibly register a "keyUp" event listener as well.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#3 kareem3d

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 January 2013 - 05:43 PM

Add this javascript code ( you have to include jquery )
  var length = $('[name="mylife"]').val().length;

  $(".edit_sub_text").html('(' + (1350 - length) + 'character limit)');


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users