Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form that has a couple of textboxes on it. I set the properties value TextMode to Number and now I have this scrollbar in the textbox. Is there a way to remove the scrollbar from the textbox and still have the textbox to only accept numbers?

ASP.NET
<asp:TextBox ID="TextBoxTRIR" runat="server" Width="180px" TextMode="Number"></asp:TextBox>
Posted

XML
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBoxTRIR"
ErrorMessage="Please Enter Only Numbers" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
 
Share this answer
 
try this.. :)

Javascript

JavaScript
var specialKeys = new Array();
      specialKeys.push(8); //Backspace

      function IsNumeric(e) {
          var keyCode = e.which ? e.which : e.keyCode
          var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);

          return ret;
      }


HTML

ASP.NET
<asp:textbox runat="server" id="txtDemo" text="12345" onkeypress="return IsNumeric(event);" xmlns:asp="#unknown" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900