开发者

How to write number of characters of a string in a textfield?

Okay, I have this textfield form that contains some text. What I n开发者_运维知识库eed 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


...textfield1.**value**.length


Using jQuery:

$('#text-input').bind('keyup', function() {
   $('#char-count-ouptput').val($(this).val().length);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜