you are here: codestackercodes [RSS] → tag count [RSS]

count chars (like twitter)

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

function countChars(idElement){
max_chars = 20;
counter = document.getElementById(idElement);
field = document.getElementById('text').value;
field_length = field.length;

// Calculate remaining chars

remaining_chars = max_chars-field_length;
if(remaining_chars<=5){
	counter.style.color="#CC0000";
}
// Update the counter on the page

counter.innerHTML = remaining_chars;
}

// <input type="input" id="text" onKeyUp="javascript:countChars('counter_number')"/> <spam id="counter_number">20</spam>
Displaying 1 Code