Posted on 2008-11-11
Greetings.. and thank you for using time to read my post..
I have a keyHandler.js file in my web-project where i have this function :
function CountLeft(field, count, max)
var target = $get(count);
if (field.value.length > max) field.value = field.value.substring(0, max);
else target.value = max - field.value.length;
.... i want to use this function on basically all textboxes in my webproject and are trying to call the function this way :
<asp:TextBox ID="txtTitle" runat="server" Width="100%" onKeyDown='CountLeft(this, "<%# lblTitleCL.ClientID %>", 50)' /><br />
<asp:Label ID="lblTitleCL" runat="server" /><asp:Label runat="server" ID="lblTitleCLDesc" Text=" characters remaining." />
... so to sum things up... lblTitleCL should display the total available characters. With no characters in txtTitle it should display "50".. on each onKeyDown it should call the CountLeft function, and display the correct amount of characters left in the label.
One problem.. is that i cannot seem to get the lblTitleCL control with this function.. am i declaring it the correct way in the function call ?
And.. how do i return the remaining characters to the label again ?
Cheers.. and thanx in advance.