Connecting Tech Pros Worldwide Help | Site Map

javascript email validation

  #1  
Old September 4th, 2008, 09:20 PM
Newbie
 
Join Date: Sep 2008
Posts: 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. tom.jones@email.com.. 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 = "";
  4.  
  5.   # Email Address
  6.   unless ($gstrHash{email} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your email address is not properly formatted.<BR>";}
  7.  
  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;   
  12.  
  13.   # Email Address
  14.   unless ($gstrHash{cemail} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your contact email address is not properly formatted.<BR>";}  
  15.  
i appreciate any help
thanks
EMI

Last edited by acoder; September 5th, 2008 at 11:51 AM. Reason: Added [code] tags
  #2  
Old September 5th, 2008, 06:06 AM
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 344

re: javascript email validation


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

Regards
Ramanan Kalirajan
  #3  
Old September 5th, 2008, 11:53 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,526
Provided Answers: 12

re: javascript email validation


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.
  #4  
Old September 5th, 2008, 02:29 PM
wgale025's Avatar
Newbie
 
Join Date: Feb 2007
Location: CN
Posts: 21

re: javascript email validation


That is php code!!!Not javascript code!
  #5  
Old September 5th, 2008, 03:00 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,526
Provided Answers: 12

re: javascript email validation


I think it's Perl actually.

@EMI, do you want this on the client-side?
  #6  
Old September 8th, 2008, 01:38 AM
Newbie
 
Join Date: Sep 2008
Posts: 4

re: javascript email validation


Sorry Guys,
yes you are right...i was wrong this is actually perl.
I guess i should post in the proper area..like 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, tom.jones@email.com).
I just want to allow periods to be submitted.
Thanks fo rthe replies
EMi
  #7  
Old September 8th, 2008, 12:38 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,526
Provided Answers: 12

re: javascript email validation


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.
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to provide password validation and also email validation for a registration form shwethatj answers 1 September 18th, 2008 03:58 PM
email validation script recommendations Morgan Packard answers 5 August 21st, 2008 09:25 PM
email validation: just enough to prevent sql injection e_matthes@hotmail.com answers 7 October 29th, 2006 05:25 PM
urgent.. email validation VbUser25 answers 4 July 22nd, 2005 01:51 AM