Click here to Skip to main content
12,358,510 members (62,862 online)
Rate this:
 
Please Sign up or sign in to vote.
hi frnds,

how to validate the Textbox with numbers. User should not enter alphabets or other characters...ONLY HE SHOULD ENTER $ DIGIT NUMBER.

user must enter only 4 digits as 2010.

So, how can we do this, do u have idea, please give me a good solution.

Thanks.
Posted 4-Jul-12 20:46pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Check following links
1) try this[^]

2)check it[^]

3) this also[^]
may be this help you

Thank you
ChetanV
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this:
void CharacterValidation(object sender, KeyPressEventArgs e)
       {
           if ((e.KeyChar >= 65 && e.KeyChar <= 90) || (e.KeyChar >= 97 && e.KeyChar <= 122) || e.KeyChar == 32 || e.KeyChar == 8 || e.Keychar != 36)
           {
               e.Handled = false;
           }
           else
           {
               e.Handled = true;
           }
       }

user must enter only 4 digits as 2010.
You need to set textBox1.MaxLength = 4;
  Permalink  
v3
Comments
Prasad_Kulkarni 5-Jul-12 3:14am
   
No reason & a down-vote from Scholar Member.

Not fair enough.

You MUST have to give reason for down-vote.
2irfanshaikh 5-Jul-12 4:51am
   
+5
Prasad_Kulkarni 5-Jul-12 5:21am
   
Thank you!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 5 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100