Regex on the fly
Se puede utilizar Regex para validaciones directamente por medio de métodos estáticos:
//Check for correct format of txtFname
Match myMatch = System.Text.RegularExpressions.Regex.Match(txtFname.Text, @"^[A-Z][a-zA-Z]*$");
if (!myMatch.Success)
{
//First Name was incorrect
ErrorMessage("Invalid First Name", "Message");
txtFieldName.Focus();
return;
}
Etiquetas: C#
