validating TextBox text

  • Thread starter Thread starter Andrea
  • Start date Start date
A

Andrea

If anyone has a simple routine to validate that text
entered in a text box control contains only numbers (zip
code) or only alpha characters (name), can you please send
me? I'm new to this, and am not looking in the right
places to find answers.
Thanks!
Andrea
 
* "Andrea said:
If anyone has a simple routine to validate that text
entered in a text box control contains only numbers (zip
code) or only alpha characters (name), can you please send
me? I'm new to this, and am not looking in the right
places to find answers.

You can use 'Double.TryParse' to check if the user entered a valid
number into the textbox. For more complex formats, you may want to use
a MaskEdit control:

FlexMaskEditBox - a masked edit control
<http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp>

Validation can be done with regular expressions too
('System.Text.RegularExpression.Regex').
 
in addition there is also an isnumeric(yourstring) function

but a zip code dousnt have to be all numbers so watch out w that one

eric
 
Back
Top