javascript - Textarea count characters validation -
i'm writing asp page using vb.net , need count number of characters in textarea , display message:"x characters remaining."
that's asp code:
<td valign='top'> <textarea rows="5" id="content_txt" name="textarea1" runat="server" maxlength="50"></textarea> </td>
here jsfiddle
html:
<textarea rows="5" id="content_txt" name="textarea1" runat="server" maxlength="50"></textarea> <p id="message"></p>
js:
var area = document.getelementbyid("content_txt"); var message = document.getelementbyid("message"); var maxlength = 50; var checklength = function() { if(area.value.length < maxlength) { message.innerhtml = (maxlength-area.value.length) + " characters remaining"; } } setinterval(checklength, 300);
Comments
Post a Comment