i have a textbox and its javascript function declared as follows
<asp:TextBox ID="TextBox1" runat="server" onKeyUp="javascript:Count(this);" TextMode="Number"></asp:TextBox>
function Count(text) {
//asp.net textarea maxlength doesnt work; do it by hand
var maxlength = 4; //set your value here (or add a parm and pass it in)
var object = document.getElementById(text.id) //get your object
if (object.value.length > maxlength) {
object.focus(); //set focus to prevent jumping
object.value = text.value.substring(0, maxlength); //truncate the value
object.scrollTop = object.scrollHeight; //scroll to the end to prevent jumping
return false;
}
return true;
}
I have also set the TextMode property of TextBox to Number, but i can still enter the Alphabet "e/E" and while entering this particular alphabet my javascript function is also not called. How should i solve this problem.