Text area length calculation not working properly in html

sveentek

New Member
hi i have a text area in my html page and i am using span tag to show its lengthhtml code:\[code\]<textarea cols="50" rows="10" maxlength="160" id="main_text"></textarea><br/><span class="charno">0</span>/160\[/code\]and i am using some jquery to show the length in span tagjquery code:\[code\]$("#main_text").keyup(function(){ $(".charno").html($("#main_text").val().length);});\[/code\]My problem is:
  • when i enter 160 characters in the textarea without pressing ENTERbutton in keyboard it shows correct result(160/160).
  • But when i use ENTER button 1 time inside the textarea, i can able to enter 159 characters only(159/160).
  • when i use ENTER button 2 times inside the textarea, i can able to enter 158 characters only(158/160).
  • when i use ENTER button 3 times inside the textarea, i can able to enter 157 characters only(157/160).
  • and so on....
is there any problem in my code or am i doing anything wrong please help.........
 
Back
Top