my question is simple, I need to know how to only allow integers to my InputBox in ASP.Net C#, without that tag thing , is there any other way ?
Thank you guys
my question is simple, I need to know how to only allow integers to my InputBox in ASP.Net C#, without that tag thing , is there any other way ?
Thank you guys
The code is :
function numericFilter(txb) {
txb.value = txb.value.replace(/[^\0-9]/ig, "");
}
call it in on key up
<input type="text" onKeyUp="numericFilter(this);" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="TextBox1" runat="server" ErrorMessage="Only Numbers allowed" ValidationExpression="\d+"></asp:RegularExpressionValidator>
You can use a asp:CompareValidator
. Like this:
<asp:TextBox ID="txtTotal" runat="server"></asp:TextBox>
<asp:CompareValidator ID="compTotal"
runat="server"
ControlToValidate="txtTotal"
ErrorMessage="ValueNotNumeric"
Type="Integer" Operator="DataTypeCheck"></asp:CompareValidator>