|
-
June 19th, 2002, 01:58 PM
#1
form validation
Hi,
I have a set of text boxes and I want to test for the type of the input, whether it's a string, decimal or integer.
If any of those do not match I want to display an error message.
How to check the strings in text boxes if they satisfy the format?
How to display an alert window?
Thank you for your help!
-
June 20th, 2002, 03:32 AM
#2
alert windows
1) There is a MessageBox Class in .net which provide you an alert window as customisable as you want.
ex.
MessageBox.Show("You must enter a name.", "Name Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Check the sdk documentation for mor information...
2) There is a Type Class in .net which provide you all the method you need to get a type to check a type...
GetType method..
Check the sdk documentation for mor information...
It is the weak who are cruel,
only the strong can be truly gentle!
Szilard
-
June 20th, 2002, 07:57 AM
#3
The problem with get type is that input to text boxes are strings.
-
June 26th, 2002, 04:55 AM
#4
Hi:
For doing validation stuff you may include the System.Text.RegularExpression namespace to your project and use the classes on it.
Take a look at http://windows.oreilly.com/news/csharp_0101.html.
You may also take a look at http://regexlib.com/Default.aspx., you will find there a lot of regular expressions.
VictorL
-
June 26th, 2002, 12:09 PM
#5
You could always just try converting them to your desired format:
Code:
try
{
myDecimal = Decimal.Parse( myTextBox.Text );
}
catch( FormatException ex )
{
MessageBox.Show( "You entered a bad number, stupid!", "Bleh!" );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|