473,395 Members | 2,006 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,395 software developers and data experts.

Validate Text - Name, Phone Etc

Hi,

I am trying to find out if there is a good (Built-in?) way to validate text
input. I would like to check a textbox to see whether user enter a proper
name (without numbers, symbols etc) or if it is a valid phone number (no
letters or symbols) etc or not. Right now I am sending the string to a
subroutine that check it each letter at a time (looping) and tries to match
it with pre-drfined chars using select case. This seems like very
inefficient way of doing this.

I would like to create these validation methods of a class and reuse them in
all my programs.

Any ideas?
Thanks.
Nov 21 '05 #1
7 1298
On Tue, 11 Oct 2005 07:34:18 -0700, "Dragon"
<ba***********@hotmail.com> wrote:
I would like to create these validation methods of a class and reuse them in
all my programs.


Have you considered regular expressions?

http://msdn.microsoft.com/library/de...onexamples.asp

Hope this helps

Cheers

Tom
tj@noemail.noemail
Nov 21 '05 #2
Dragon,

This would not be new as it was in 2003

http://msdn2.microsoft.com/en-us/library/wdt8exfc

I hope this helps,

Cor
Nov 21 '05 #3
Thank you Tom.

Would you be able to help me a bit more? I am readin up on regular
expressions but, for some reason, I am a bit confused. It seems I am doing
pretty much ( or close to ) same thing I was doing when comparing one letter
at a time.

For example, I have a string "Jon9y Smith" and I want to make sure that it
is a valid name or not. I will have to either check each char at a time to
make sure there is no char ourside (a-z, A-Z, " ") orsimply check for a
space and assume the names are typed correctly.

Am I missing something here? Any better example I could look at?

thank you.
"Tom John" <tj@noemail.noemail> wrote in message
news:jp********************************@4ax.com...
On Tue, 11 Oct 2005 07:34:18 -0700, "Dragon"
<ba***********@hotmail.com> wrote:
I would like to create these validation methods of a class and reuse them
in
all my programs.


Have you considered regular expressions?

http://msdn.microsoft.com/library/de...onexamples.asp

Hope this helps

Cheers

Tom
tj@noemail.noemail

Nov 21 '05 #4
Regular Expression validation is the way to go.

\d - will find any digits in the string
[0-9] - digits 0 - 9
[~!@#$%^&*()-_+=\|][{}<>?,./] - self-explanatory

Nov 21 '05 #5
Thank you Will.

I am beginning to understand that I can easily exclude certain characters.
The main problem I have with this method is that there are too many to
exclude. A user can easily add non a-z char by simply using the Alt
combination. Trying to exclude each one of those could take forever.

I guess I will do some more research to see if I can have an 'include' list
instead of 'exclude' list.

Thank you.
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Regular Expression validation is the way to go.

\d - will find any digits in the string
[0-9] - digits 0 - 9
[~!@#$%^&*()-_+=\|][{}<>?,./] - self-explanatory

Nov 21 '05 #6
Thank you Cor. I will definately have to give it a try. What would you say
which method is better, more efficient, using MaskedTextBox or using Regular
Expressions?

Thanks.
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
Dragon,

This would not be new as it was in 2003

http://msdn2.microsoft.com/en-us/library/wdt8exfc

I hope this helps,

Cor

Nov 21 '05 #7
Dragon,

I did not use the MaskedTextBox yet and probably are not able to do that for
a telephon number (we have in Europa a lot of formats for that, only here in
Holland there are even more than one), however I think if you are able to
use it, than it will obviously be better because it is more direct to the
user.

Cor
Nov 21 '05 #8

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

Similar topics

11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
3
by: Lord0 | last post by:
I *think* I need to be able to validate subsets of an XML document using different schema. The functionality I'm trying to implement is this. a) External suppliers produce an XML document...
11
by: TokyoJ | last post by:
I run a small camp in Alaska for kids and my director is asking for a web form. Could someone please have a look and offer some advice on where I'm making mistake(s)? I'm using the RegExp function...
2
by: Neo Geshel | last post by:
Greetings, I have a form with a telephone field. It is very specific, as it has four text boxes - the country code, area code, prefix and suffix. I can validate each of them individually, but...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: jhansi | last post by:
hi... I have created a form it's working properly.... but i want to consider phone number and STD code in two different text field for a single lable phone number..... and I have considered...
5
by: Abhishek | last post by:
Hi this is my another validator in javascript to validate the Phone Number :-) <script language='javascript'> function funcCheckPhoneNumber(ctrtxtMobile,e){ if(window.event){ var strkeyIE =...
5
by: ghjk | last post by:
I have a web site with several web pages. They are having different number of variables. eg: first page having 4 variables in the form(Name, Phone, ID, Gender) second page having 10 variables in the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.