PC Review


Reply
Thread Tools Rate Thread

basic .net validation

 
 
Gary
Guest
Posts: n/a
 
      29th Jan 2007
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.
 
Reply With Quote
 
 
 
 
Peter Bradley
Guest
Posts: n/a
 
      30th Jan 2007
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

"Gary" <(E-Mail Removed)> wrote in message
news:uQzqsQ$(E-Mail Removed)...
> 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.



 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      30th Jan 2007

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


Hi,
For the "First name" field validation the expression [A-Z][a-z]+ maybe
will be more suitable.

 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      30th Jan 2007
Could be - but it wasn't what the spec said.

)


Peter

"marss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Peter Bradley wrote:
>>
>> Regex rx = new Regex(@"^[a-zA-Z]{2,}$");
>>

>
> Hi,
> For the "First name" field validation the expression [A-Z][a-z]+ maybe
> will be more suitable.
>



 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      30th Jan 2007

Peter Bradley wrote:
> Could be - but it wasn't what the spec said.
>
> )
>
>
> Peter


It seems to be logical , but I don't insist.

 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      30th Jan 2007
Whoever saw a logical spec??

Sorry, my cynicism is showing.


Peter


"marss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Peter Bradley wrote:
>> Could be - but it wasn't what the spec said.
>>
>> )
>>
>>
>> Peter

>
> It seems to be logical , but I don't insist.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic way to make basic databases work on Access2007? Fred Microsoft Access 5 8th Apr 2010 04:47 PM
have window vista basic.understand basic don't have fax & scan jay sureka Windows Vista Print / Fax / Scan 4 7th Jan 2008 07:02 PM
Basic data validation question Bingo Accent Microsoft Excel Discussion 4 8th Mar 2007 10:33 AM
Validation: Basic Problem from a new user =?Utf-8?B?RGFtbzQ0Nw==?= Microsoft Access Database Table Design 4 10th May 2006 05:08 AM
Basic Validation problem =?Utf-8?B?RGFtbzQ0Nw==?= Microsoft Access 1 9th May 2006 08:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:20 AM.