you are in: codestackercodes [RSS]count chars (like twitter)

count chars (like twitter) Delicious Email

http://woork.blogspot.com/2008/07/useful-tips-to-enrich-your-html-forms.html

show/hide lines
   1  function countChars(idElement){
   2  max_chars = 20;
   3  counter = document.getElementById(idElement);
   4  field = document.getElementById('text').value;
   5  field_length = field.length;
   6  
   7  // Calculate remaining chars
   8  remaining_chars = max_chars-field_length;
   9  if(remaining_chars<=5){
  10  	counter.style.color="#CC0000";
  11  }
  12  // Update the counter on the page
  13  counter.innerHTML = remaining_chars;
  14  }
  15  
  16  // <input type="input" id="text" onKeyUp="javascript:countChars('counter_number')"/> <spam id="counter_number">20</spam>
created by leozera — 22 November 2008 — get a short url — tags: count javascript twitter embed

Comments



We dont send spam :)

If checked, it's highlights your comment
simple_captcha.jpg
Are you a human? Type the code from the image