Suppose we have a testbox and you dont want to allow comma in the textbox.Below is the code to do so :
function checkKey(ele, event) {
var v = ele.value.substring(0, ele.value.length);
if (event.keyCode == 188) {
alert("Invalid Character");
$("#<%=lccode.ClientID %>").val(v);
}
else {
return true;
}
}
And here us the textbox code to call function :
<asp:TextBox ID="lccode" runat="server" Width="200px" TextMode="MultiLine" Height="30px"
onKeyDown="checkKey(this,event)"></asp:TextBox>
function checkKey(ele, event) {
var v = ele.value.substring(0, ele.value.length);
if (event.keyCode == 188) {
alert("Invalid Character");
$("#<%=lccode.ClientID %>").val(v);
}
else {
return true;
}
}
And here us the textbox code to call function :
<asp:TextBox ID="lccode" runat="server" Width="200px" TextMode="MultiLine" Height="30px"
onKeyDown="checkKey(this,event)"></asp:TextBox>
Comments
Post a Comment