Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i make a textbox which accept limited intergers value, the value should upto 10 integers.. thanks.
Posted
Comments
TrushnaK 21-Apr-13 4:42am    
limit means. its length or integer 10 and you don't want 11,12 etc.

On keypress event check for integer for exa.
C#
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            int result;
            if (int.TryParse(e.KeyChar.ToString(), out result))
            {

            }
            else
            {
                e.Handled = true;
            }

        }

and for 10 digit set textboxs MaxLenght property to 10 ..then it will accept only 10 digits
 
Share this answer
 
you can use RegularExpressionValidator and make ValidationExpression="^\d+$"
 
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