about regular expression validation
-
gud afternoon i have a problem i have a taextbox and i want to enter in it only 2 digits or 11 digits example 12 valid 123 invalid 12345678912 valid 123456789123 invalid plz. rply its urgrnt
-
gud afternoon i have a problem i have a taextbox and i want to enter in it only 2 digits or 11 digits example 12 valid 123 invalid 12345678912 valid 123456789123 invalid plz. rply its urgrnt
You don't need Regex(Regular Expression) Use can use Leave event :
private void textBox1_Leave(object sender, EventArgs e)
{
if (textBox1.Text.Length != 2 && textBox1.Text.Length != 11)
throw new Exception("invalid");
}modified on Saturday, November 7, 2009 10:03 AM
-
You don't need Regex(Regular Expression) Use can use Leave event :
private void textBox1_Leave(object sender, EventArgs e)
{
if (textBox1.Text.Length != 2 && textBox1.Text.Length != 11)
throw new Exception("invalid");
}modified on Saturday, November 7, 2009 10:03 AM
I think you want an
&&
, not an||
. -
I think you want an
&&
, not an||
.Yeah, You're right. Thanks