473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

basic .net validation

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.
Jan 29 '07 #1
5 980
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" <g@nospam.comwrote in message
news:uQ**************@TK2MSFTNGP03.phx.gbl...
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.

Jan 30 '07 #2

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.

Jan 30 '07 #3
Could be - but it wasn't what the spec said.

:o)
Peter

"marss" <ma***@ukr.netwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
>
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.

Jan 30 '07 #4

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

:o)
Peter
It seems to be logical :), but I don't insist.

Jan 30 '07 #5
Whoever saw a logical spec??

Sorry, my cynicism is showing.
Peter
:)

"marss" <ma***@ukr.netwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
>
Peter Bradley wrote:
>Could be - but it wasn't what the spec said.

:o)
Peter

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

Jan 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Barry | last post by:
The MS fix for IE broke how users access our site (if they patch their browsers), so I need a solution to get users logged onto our site transparently. Basically we used to log on to the site...
6
by: Bliss | last post by:
ok I am rather new to the .net framework. I come from a J2EE background. I am not a java snob though =-) I happen to like both platforms. At any rate I came accross a simple problem that I was...
27
by: code_wrong | last post by:
Visual Basic (not dot net) what is the best way to check the User has entered an integer into an InputBox? isNumeric() checks for a numeric value .. but does not notify of numbers with decimal...
5
by: anianu | last post by:
i want to know how to do validation in visual basic.means how to avoid entering numbers in textbox where we need only characters and also opposite means how to avoid characters where we only need...
1
by: =?Utf-8?B?TW9ydG9u?= | last post by:
I added two buttons to a web page. One has 'Causes Validation' set to True - the othe to false. When I click the button set to 'Causes Validation' - the expected validation messages appear. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.