473,799 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Validation for email address?

1 New Member
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 2147
GaryTexmo
1,501 Recognized Expert Top Contributor
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@som ewhere.com" is valid, I believe. So is "alberta.govern ment.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
8173
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
6511
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 $email = $_POST // Use John Coggeshalls script to validate the email address if(!eregi("^+(\.+)*@+(\.+)*(\.{2,3})$", $email) { echo "The e-mail was not valid";
2
451
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 an email with single quotes --example jane.O'brian@yahoo.com -- I would like to be able "to allow" single quote on the email address. Can anyone help me out !! Thanks ahead, Angel
35
3364
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 this kind of routine. -- Thanks in advance! Mika
2
1717
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 have given a valid email address before allowing them access to restricted content. Will Auth facilitate the email validation process, or does it only deal with usernames and passwords? I don't need to be told in detail how to do all this, but...
2
1062
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
3144
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 numbers. Now i use this script for validate the email address. But it allows the cpital letters otherwise its working correctly. SCRIPT FUNCTION ************************************************
2
2533
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 doesn't run the rest. I want to log the one that crashed so I can display it to the user and then continue sending to the remaining people in the list. If an address is bad, the error occurs here: EmailMsg.To.Add(New MailAddress(RecipientEmail,...
4
8776
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 by one thing or another, and tell me valid addresses are invalid. Thanks! John
3
1293
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
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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
9073
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
7565
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
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
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
4141
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
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.