Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a web forms application with varying types of controls. I have a textbox that as of right now only accepts numeric values. As soon as I type a letter, the letter will appear and then backspace. I don't have this issue when entering numeric values.

Here is the html that creates the textbox:
XML
<div class="FloatLeft">
                <span class="DataPromptLeft">Alpha Number</span><span class="RequiredIndicator"></span><br />
                <asp:TextBox ID="uxLineNumTxt" runat="server" CssClass="TextControlMedium" MaxLength="14" onkeyup="NumericKeyUp(this);" Width="152px"></asp:TextBox>
            </div>

I believe the onkeyup="numericKeyUp(this); is what is making my textbox behave as previously described. I researched this issue as well as the onkeyup purpose/ functionality. Everything I came across was oriented towards getting a textbox to only accept numeric values, which is the opposite of what I want.

Any ideas on how to approach this?
Posted
Updated 17-Aug-15 3:57am
v2
Comments
Sergey Alexandrovich Kryukov 17-Aug-15 10:08am    
By default, TextBox accept any characters. So, what's the problem? If you have a code sample with a text box filtering input to accept only numbers, you know how to do filtering. Do exactly what you want.
—SA

1 solution

If you don't want to filter the characters entered into the textbox, then remove the onkeyup attribute. The javascript function name "NumericKeyUp" suggests that this is what's causing the behaviour you're seeing.
 
Share this answer
 

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