basic .net validation

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Hello,

I would like to do several checks on a field "First name".

I would like to check for the following:

No numbers
No spaces
Two characters or more

Anyone know the best way to achieve this?

Regards,

Gary.
 
I assume that you also don't want characters like !"£$%^&*()_-+= and so on??

In which case:

using System.Text.RegularExpressions;

Regex rx = new Regex(@"^[a-zA-Z]{2,}$");

if (rx.IsMatch(txtFirstName.Text))
{
...
}

Off the top of my head, but HTH


Peter
 
Back
Top