Hello,
I am trying to incorporate Javascript with ASP. I want to display in the Label how many characters the client has remaining in the textbox. The Label is not changing at all - any ideas?
<script type="text/javascript">
function CheckCharCount(textBox, maxLength) {
var charCount = maxLength - texBox.value.length;
document.getElementById("lblCharCount").innerText = ";
if (charCount >= 0) {
//within limit - display in black
document.getElementById("lblCharCount").style.color = "black";
}
else {
//negative chars - display in red
document.getElementById("lblCharCount").style.color = "red";
}
}
</script>
<form runat="server">
<div>
<asp:Label ID="lblCharCount" runat="server">500 Characters Remaining</asp:Label>
<asp:TextBox ID="textBox" runat="server" Height="53px" TextMode="MultiLine" onkeyup="CheckCharCounter(this, 500)"/>
</div>
</form>
Thanks,
Brittany