i need a textbox and button
in textbox i have to keep validation in windows form
in text box 1st letter should start with 3
and 2nd letter should start with R||c
I MEAN R OR C
3rd and 4th should be OF||OH||OD
5TH LETTER SHOULD BE B or 0-9
and 6th to 12th it should be a numbers
only
total it should not exceed 12words in textbox
VulpesPosted Mar 13, 2014, 6:23 PM
When you say there should not be more than 12 words in the TextBox, I assume you mean that there shouldn't be more than 12 characters but (presumably) at least 6:
using System.Text.RegularExpressions;
// ...
string r = @"^3(R|C)(OF|OH|OD)(B|\d)\d{1,7}$";
bool isValid = Regex.IsMatch(textBox1.Text, r);
Note that the above is case sensitive.
if you want it case insensitive, then change the regular expression to:
string r = @"^(?i)3(R|C)(OF|OH|OD)(B|\d)\d{1,7}$";
vijay kumarPosted Apr 30, 2014, 5:09 AM
Shweta LodhaPosted Mar 13, 2014, 5:11 PM