Click here to Skip to main content
15,908,115 members

Comments by Member 10686581 (Top 14 by date)

Member 10686581 28-Nov-14 11:04am View    
Still the same problem
Member 10686581 21-Mar-14 12:27pm View    
Yeah I've done that now here is the code I have used:

private void btnCheck_Click(object sender, EventArgs e)
{

String AllowedChars = ("^(?!PAN)(?!SOS)[A-Z]{3}\\d{4}$");
if (Regex.IsMatch(txtIdentification.Text, AllowedChars))
{
MessageBox.Show("Valid");
}
else
{
MessageBox.Show("Invalid");
}

}

When I enter a PAN or SOS I need it to give me a different output, how do I do this?
Member 10686581 21-Mar-14 12:13pm View    
Thank you this looks like what I'm looking for but I need the code for windows form.

I have a textbox and a button, once the button is clicked it needs to check what the user has inputted in the textbox, how would I go about adapting your code in this way? I would need to display the valid and invalid outputs in either another textbox or as an error message.
Member 10686581 21-Mar-14 12:04pm View    
It's not me whos idea it is to let the user input an incorrect format lol, it just needs to be able to display a message saying invalid format.. I tried to create a regular expression for the format of LLLNNNN using a program but it just gives me: [a-zA-Z]{3}[0-9]{4}

Once I get the expression could I just use it like this:

private void textBox5_Validating(object sender, CancelEventArgs e)
{
String AllowedChars = [a-zA-Z]{3}[0-9]{4};
if (Regex.IsMatch(textBox5.Text, AllowedChars))
{
MessageBox.Show("Valid");
}
else
{
MessageBox.Show("Invalid");
}
}
Member 10686581 21-Mar-14 11:37am View    
I don't think masking will work because when the user inputs the ID, I need to display whether it is valid or invalid in another text box.. if I used masking it would let the user only enter in a valid format so it leaves no room to enter an invalid one.

Just looked at the regular expressions, it's so confusing!