11
I tried to make one, but always ran into some limitation. I think my logic will not work, but I still could not think of another.
Javascript:
$(document).on("keydown", "#TxtObservacoes", function () {
var caracteresRestantes = 255;
var caracteresDigitados = parseInt($(this).val().length);
var caracteresRestantes = caracteresRestantes - caracteresDigitados;
$(".caracteres").text(caracteresRestantes);
});
HTML:
<span class="caracteres">255</span> Restantes <br>
<textarea id="TxtObservacoes"></textarea>
My code: http://jsfiddle.net/5pw5L/
Ta further what are the limitations of its implementation? Just to understand the problem.
– Fernando Leal
If I use keydown the textarea has not yet added the typed text and the wrong account. If I use keypress it does not detect Backspace for example. In the fiddle you can see that.
– Joao Paulo