Monday, February 14, 2011

Validating string with atleast 1 number and 1 letter c#

Regex re = new Regex(@"\d+");

Match m = re.Match(TextBox2.Text.Trim());

Regex relt = new Regex(@"^[a-zA-Z]+$");

Match n = re.Match(TextBox2.Text.Trim());

 

if (m.Success && n.Success)

{

//errcd = "Error";

// Label8.Text = string.Format("RegEx found " + m.Value + " at position " + m.Index.ToString());

//Response.Write("asssaas");

}

else

{

errcd =

"Error";

//Response.Write("22222");

//Label8.Text = "You didn't enter a string containing a number!";

}

No comments: