Professional Documents
Culture Documents
Validation For A Text Box With Alphanumeric - CodeProject
Validation For A Text Box With Alphanumeric - CodeProject
Validation For A Text Box With Alphanumeric - CodeProject
Ask a Question All Questions All Unanswered FAQ
Hi All,
I am new to C#. I need a validation for a text box. Text box may contain alphanumeric but only numbers is not
allowed. How can i do that. It is in C# windows application.
Related Questions
Comments
Solution 2
Try this
C#
Solution 3
Try Regex.Match, see example:
C#
using System;
using System.Text.RegularExpressions;
if (match.Success)
{
Console.WriteLine("passed");
}
else
{
Console.WriteLine("failed");
}
}
}
Solution 4
In addition to Solution 1 (sankarsan parida) which allows you to enter only letters and digits in you text box
control, you can check that textbox is containing at least one letter this way:
C#
Solution 5
Some very valid solutions given (in particular from Sankarsan Parida), but no-one has mentioned where to put
the check that the text is not all numbers.
The following should work for both only allowing alphanumeric to be entered and for checking it is not all
numeric (once the user has finished entering data) ...
C#
Add a Solution
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