I have this textbox that has the limit in DB for input 255. And I am trying to built a function in JS that stops the user for inserting more than 255 characters in that textbox.
Here is the asp.net code:
<asp:TextBox Id="textbox" TextMode="MultiLine"
oninput="F(id,this.value.length, 255)"
runat="server" Columns="25" Rows="5"></asp:TextBox>
And here is the code in JS(just a test):
this.textCounter = function (ref,value, maxlimit) {
if (value > maxlimit) {
$('#textbox').value=" ";
}
return true;
}
Somehow the $('#textbox').value is undefined.
What I can do?
jQuerythen it has methodvalfor getting/setting value i.e.$('#textbox').val("aaaa");for setting and$('#textbox').val();for getting.valueis a property in javascript and your are using jQuery object thus your code was not working.