This is actually a solution to that issue... Something so simple, but overlooked by me.
- <asp:TextBox id="tbDescription" runat="server" Height="78px" TextMode="MultiLine" onkeypress="check(this)" Width="363px"></asp:TextBox>
-------------------------------------------------------------------------------------------------------------------
- <script language="javascript" type="text/javascript">
-
function check(textbox)
-
{
-
var maxLen = 500;
-
-
if (textbox.value.length >= maxLen)
-
{
-
var msg = "You have reached your maximum limit of characters allowed";
-
alert(msg);
-
textbox.value = textbox.value.substring(0, maxLen);
-
}
-
}
-
</script>
I got that from hollystyle on another forum...
"Now it doesn't matter what the textbox is called as it passes a reference to itself to the javascript function. This is loosley coupled programming the function's responsibilty is to check the length of a textbox value and that's it, it shouldn't have 'knowledge' of the textbox's id."