473,698 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1308
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.noe mail> wrote in message
news:jp******** *************** *********@4ax.c om...
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****@brinkst er.net> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.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******** ******@TK2MSFTN GP10.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
11758
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 in the validated event. Is there a way to know if all validated controls pass validation when the user clicks an OK button? In ASP.Net there's the Page.IsValid method. Is there something similar in winforms, or do I still have to write an...
3
1754
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 containing multiple User records. The external supplier validates this entire document using schema 1. This document is then uploaded to our system. b) Our system then checks that the supplied document "looks okay", minimally, using Schema 2. Schema...
11
8171
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 to validate 3 types of fields: text, radio button, dropdown menu. but the code doesn't validate. After 2 days, it's time I asked for guidence. Criteria: Text: only alphabet, no numerals, allowed Radio: one must be selected, Dropdown: an option...
2
2393
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 I am stumped as to how to validate them as a group (as one final validation). I need to check to see if all (at one time) are filled or empty. The other individual validations handle cases where the text boxes are filled with letters or ...
1
4000
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. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
1
5901
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 the fields like first name,last name,Date of birth, Phone Number ,mobile number and address... 1)If i enter all the fields then only the values should enter into the database... 2) if i dint enter the mobile field then also it should save into...
5
3675
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 = e.keyCode if(((strkeyIE >= 48) && (strkeyIE <= 57 )) || (strkeyIE >= 40) && (strkeyIE <= 41 ) || (strkeyIE == 32) || (strkeyIE == 46)||(strkeyIE
5
2636
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 form(eg: Name, Age, Time, etc.) I want to validate each and every variable. So how can I do that? I found this JavaScript.But in this case for each and every variable I have to write a function.Eg:for each and every variable i have to rewrite the...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.