473,386 Members | 1,798 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,386 software developers and data experts.

E-mail validation

10
Hi there,

I'm using this code for e-mail checking:

[PHP]
if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email)) {
echo "<span style=\"color: red; font-weight: bold; \">Registration errors have occured:</span><br />You entered an invalid email address.<p>Please go <a href=\"javascript:history.go(-1)\">previous page</a> and try again.</p>";
} else {
// registration codes
}
[/PHP]

But, example, if my email address is hello.there@address.net registration have error. Why?

Thanks
Nov 27 '06 #1
1 1137
ronverdonk
4,258 Expert 4TB
Your regular expression only allows alphabetic chars and numeric digits before the @.
In ordet to handle that use the pattern in the following function:
Expand|Select|Wrap|Line Numbers
  1. function valid_email ($str) {
  2.  return  (ereg ('(^[0-9a-zA-Z_\.-]{1,}@([0-9a-zA-Z_\-]{1,}\.)+[0-9a-zA-Z_\-]{2,}$)', $str));
  3. }
Ronald :cool:
Nov 27 '06 #2

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

Similar topics

1
by: Marlon | last post by:
How can modify this expression \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* to validate multiple email address separator by comma and/or semicolon e.g. someone@somedomain.com;someone2@somedomain.com
4
by: VbUser25 | last post by:
Hi Please suggest i think i am doing something wrong. I am calling fucntion test from another function where i am performing all the validations.I want to validate the email id. this is the...
2
by: AFN | last post by:
Has anyone written any code to verify an email address against an SMTP server? I hear you can see if the address is an alias (catchall) versus a real account. I know you can telnet on port 25...
1
by: Jim Dornbush | last post by:
Has anyone seen an updated regex expression from Microsoft for the email validation expression so that single quotes are allowed? I've been using the canned regex for emails, but recently been...
7
by: e_matthes | last post by:
Hello everyone, I've read enough about email validation to know that the only real validation is having a user respond to a confirmation message you've sent them. However, I want to store the...
10
by: ll | last post by:
Hi, I currently am using the following regex in js for email validation, in which the email addresses can be separated by commas or semicolons. The problem, however, lies in that I can type two...
1
by: vimal.424 | last post by:
Hello guys........ please tell me ............. I want to do email validation like i have a userid entered by user new user.so problem is that i have to do the validation when i'll click...
1
by: shwethatj | last post by:
My problem is lik this , I am trying to create a registration form using javascript for a HR website , but i dont know how to provide password validation i.e the password and confirmation password...
1
by: curi444 | last post by:
How can i improve email validation in the code below? <?php $con = mysql_connect("localhost", "root", ""); if(isset($_POST)) { $name=$_POST; $address=$_POST; $phno=$_POST;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
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,...

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.