How to get textbox character' count in Javascript?

 Posted by Rajesh_Kumar on 1/21/2014 | Category: JavaScript Interview questions | Views: 964 | Points: 40
Answer:

With the help of Length property of textbox control,we can count number of characters:-

<asp:TextBox ID="TextBox1" runat="server" Text="Rajesh Kumar"></asp:TextBox>


var count = document.getElementById('<%=TextBox1.ClientID %>').value.Length;
alert(count);


Output:12


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response