views:

22

answers:

2
<input type='text' name='one' id='oneID' maxlength="150"> 

i need the JS to display the number of characters left that user can input

alt text

a picture is worth a 1000 words so no more explanation required...

A: 

Bind a function to the onkeyup event that counts the number of characters entered and displays how much is remaining.

Example:

var e = document.getElementById('oneID'),
    f = document.getElementById('countDiv'); // some element where the count will be displayed

e.onkeyup = function() {
  f.innerHTML = (e.maxLength - e.value.length) + ' characters remaining';
}
casablanca
didn't work....
Junaid Saeed
Do you have the right IDs? Is the DOM ready before you run the js? The code is fine. http://jsfiddle.net/yGdBg/
Rfvgyhn
i got everything rite but still not working but because its working on jsFiddle.. am gonna accept
Junaid Saeed
A: 

               

Junaid Saeed
just testing if i can have empty posts empty
Junaid Saeed