How to count the number of characters that is entered in a text box?

I have a label lblCountCharacterwith the text "4000" and a text box txtAddNotewhere users can enter text.

When you enter one character in the txtAddNotetext label decreases by one.

Please help me write a function for this in asp.net using C #.

+5
source share
4 answers

I think you can get a better solution for this using only javascript / jQuery. The use of C # will be associated with the need to use AJAX to re-render the tag every time.

var characterLimit = 4000
var charLeft = characterLimit - $(".textbox").val().length
$(".label").html(charLeft);
+2
source

, jQuery :

var myLength = $("#myTextbox").val().length;
+4

, javascript. , .

.

+2

javascript . onkeypress javascript, , .

+1

All Articles