By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,685 Members | 1,902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,685 IT Pros & Developers. It's quick & easy.

javascript email validation

P: 4
Hello, im posting this question because i have zero knowledge on javascrip. I have a script which curently allows users to imput an email address and if the email is not valid it wont allow the submission. Everything works fine except that now there are clients who have a period in their email address and it is rejected. eg. im sure its a simple addition to the script not even sure where it might go but here is what i copied and where im assuming it might need to be changed..

Expand|Select|Wrap|Line Numbers
  1. # Do our error checking
  2.   my $gintErrorCount = 0;
  3.   my $gstrMessage = "";
  5.   # Email Address
  6.   unless ($gstrHash{email} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your email address is not properly formatted.<BR>";}
  8.   # Fix phone variable - client
  9.   $gstrHash{cphone} =~ s/\D//g;
  10.   unless ($gstrHash{cphone} =~ m/^\d{10}$/) {$gintErrorCount ++; $gstrMessage .= "Your contact phone number must be a ten digit number.<BR>";}
  11.   $gstrHash{cphone} =~ s/^([\d]{3}?)([\d]{3}?)([\d]{4}?)$/\($1\)$2-$3/i;   
  13.   # Email Address
  14.   unless ($gstrHash{cemail} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your contact email address is not properly formatted.<BR>";}  
i appreciate any help
Sep 4 '08 #1
Share this Question
Share on Google+
6 Replies

P: 607
I am sorry i am not able to get your requirement clearly. what u are trying to add in that script. you specified that the client has a period in email id. What is that you wnat to mean. I was not able to get ur point at that line. Are u checking for duplication or checking for any time constraint. please mention it clearly. I will try to help u out

Ramanan Kalirajan
Sep 5 '08 #2

Expert Mod 15k+
P: 16,027
That's not JavaScript code. Are you sure this is on the client-side?

Whatever the case is, you just need to make a change to the reg. exp. to allow a . within the email.
Sep 5 '08 #3

P: 23
That is php code!!!Not javascript code!
Sep 5 '08 #4

Expert Mod 15k+
P: 16,027
I think it's Perl actually.

@EMI, do you want this on the client-side?
Sep 5 '08 #5

P: 4
Sorry Guys,
yes you are right...i was wrong this is actually perl.
I guess i should post in the proper i mentioned im clueless about this stuff...
Yes this is actually a form that requires whoever goes to the site to imput an email address. Everything works great but since poeple now have a period in the emails..whatever restrictions have been coded with the email requirements dont allow for periods in the first part of the email (eg,
I just want to allow periods to be submitted.
Thanks fo rthe replies
Sep 8 '08 #6

Expert Mod 15k+
P: 16,027
I was about to move this thread when I realised that you've already posted in the Perl forum. If you ever need client-side email validation, you can come back to this thread.
Sep 8 '08 #7

Post your reply

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