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

Data Validation for email address?

I'm having a hard time with the requirements asked of me since I'm really new to programming. What I'm making is a windows application. I've been able to have data validations for only one @ sign and the string not starting with a period or symbol, but I'm having problems with two things:

1. Having only 1 period AFTER the single @ but allowing more than one before it.
2. Preventing the user from entering multiple periods (the hint was that I could use something similar to trim functions -- I'm using a custom trim function for spaces)

What I've been taught was to use either Keypress or TextChanged event and put the codes there. I would like to know where to start.
Feb 15 '12 #1
1 2132
GaryTexmo
1,501 Expert 1GB
This sounds a bit like a homework assignment and this forum has pretty strict rules about helping people with homework assignments. I can't really give you answers here but maybe I can give you a few nudges in the right direction.

1) If there's no requirement on how you need to approach this, it might be a good idea to have a look into using Regular Expressions to validate your e-mail string. They were made for this kind of thing so you might find that helpful.

2) If you absolutely must do it with string functions, you are doing it on the TextChanged event (or KeyPress) so you know what characters are coming. Perhaps keeping counts and setting flags might be appropriate? Also have a look at the string.Contains and string.IndexOf methods.

3) You mentioned preventing the user from entering multiple periods... is that correct? An e-mail of "gary.texmo@somewhere.com" is valid, I believe. So is "alberta.government.emails.may.look.like.this@gov. ab.ca". You may wish to clarify on that requirement.

Good luck!
Feb 15 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: aaron | last post by:
I need some help with validating an email address. Right now, I am doing this: function sys_is_valid_email ($s) { if (preg_match ("/^.+@.+\..+$/", $s)) { return 1; } else { return 0; } }
25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
2
by: Angel | last post by:
Hi there, I need help pls..I'm using c# on a webform and I have this regex validation for email addresses: ValidationExpression ="\w+(\w+)*@\w+(\w+)*\.\w+(\w+)* " I'm having isssues when submit...
35
by: Mika M | last post by:
Simple question: Does Framework (1.1) contain any routine to check entered email-address is valid ? It's quite easy to make own code for that purpose, but why to do if Framework (1.1) contain...
2
by: e_matthes | last post by:
Hello everyone, I am about to implement an authentication system on the site I am building. I don't care much what users choose for their username and password, but I want to verify that users...
2
by: mcasaurabhsumit | last post by:
hello friend, i have a form with data. how to send forms data to email address? plz. send me the answer? and code for it.
1
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
2
by: Keith G Hicks | last post by:
I'm using the following code to send out email messages to a list of people in a database. My problem is that if I'm sending to 100 people and the 40th address is bad, it crashes on that one and...
4
by: JvC | last post by:
Does anyone have a good routine for EMail address validation? The one that I use is fairly primitive, and I need to beef it up. I have downloaded several from the web, and they all get screwed up...
3
by: John Wright | last post by:
I want to validate an email address against our Exchange server. Anyone have code or point me in the right direction? John
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:
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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,...
0
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...

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.