javascript email validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emirapoport
    New Member
    • Sep 2008
    • 4

    javascript email validation

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

    Code:
    # Do our error checking
      my $gintErrorCount = 0;
      my $gstrMessage = "";
      
      # Email Address
      unless ($gstrHash{email} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your email address is not properly formatted.<BR>";}
      
      # Fix phone variable - client
      $gstrHash{cphone} =~ s/\D//g;
      unless ($gstrHash{cphone} =~ m/^\d{10}$/) {$gintErrorCount ++; $gstrMessage .= "Your contact phone number must be a ten digit number.<BR>";}
      $gstrHash{cphone} =~ s/^([\d]{3}?)([\d]{3}?)([\d]{4}?)$/\($1\)$2-$3/i;   
    
      # Email Address
      unless ($gstrHash{cemail} =~ m/^(\w+)\@(\w+)\.(\w{2,4})$/)  {$gintErrorCount ++; $gstrMessage .= "Your contact email address is not properly formatted.<BR>";}
    i appreciate any help
    thanks
    EMI
    Last edited by acoder; Sep 5 '08, 10:51 AM. Reason: Added [code] tags
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    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

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      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.

      Comment

      • wgale025
        New Member
        • Feb 2007
        • 23

        #4
        That is php code!!!Not javascript code!

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          I think it's Perl actually.

          @EMI, do you want this on the client-side?

          Comment

          • emirapoport
            New Member
            • Sep 2008
            • 4

            #6
            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..whateve r 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

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

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

              Comment

              Working...