Reputation: 1110
Okay, I have this textfield form that contains some text. What I need to do is to count number of characters of that particular string and print it into another textfield form, basically like this:
function numberOfCharacters() {
var number = document.forms[0].textfield1.length;
document.forms[0].textfield2.value = number;
}
When I do this, textfield2 contains "undefined" string. Thank you
Upvotes: 1
Views: 213
Reputation: 2312
Using jQuery:
$('#text-input').bind('keyup', function() {
$('#char-count-ouptput').val($(this).val().length);
});
Upvotes: 0