Announcement

Collapse
No announcement yet.

Validate email in pearl

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Validate email in pearl

    Hi all,

    I've noticed on a number of occasions that PROTX cannot proceed because customers have entered an invalid e-mail address - most of the time it is because the customer has entered a comma in place of a full-stop (or 'dot' if you prefer).

    Now I know that there is some e-mail address validation in the OrderScript.pl script which contains the following line:

    $::g_BillContact{'EMAIL'} !~ /\@/) # and it is not in the expected format

    I'm not a pearl person, so at a guess I think this line is making sure a @ sign exists.

    Are there any pearl experts out there who could help to enhance this code to look for an e-mail in the format xxx@xxx.xxx where x is any valid character (a-z, 1-0, ".", "-")?

    Thanks
    Raj

    P.S. I know it is possible to do some validation in Javascript, but I wanted to adapt the pearl script so that an error is reported to the customer in the standard actinic way.

    #2
    By joe, I think I've found it!

    Having posted on this forum, I continued gigging around the net, and I think I have found the answer.

    First, this is where I found the answer:
    http://fightingforalostcause.net/mis...mail-regex.php

    So, here's the fix:
    1. Open OrderScript.pl which is in the site1 folder.
    2. Search for the line: $::g_BillContact{'EMAIL'} !~ /\@/)
    3. Comment out and replace with the line: $::g_BillContact{'EMAIL'} !~ /^([a-zA-Z0-9_'+*$%\^&!\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9:]{2,4})+$/)

    Save and upload.

    This script will now check for a correct format of invoice e-mail address (obviously just the format, and not that the e-mail address itself is valid).

    Not sure why, but it doesn't seem to do the same check for the delivery e-mail address, but this is less of a problem as it does not affect PROTX for me.

    Have I missed anything?

    Raj

    Comment


      #3
      Hi

      I also need to implement this as we appear to be getting a fair few failed orders due to incorrect email formatting. However I am even more afraid of touching perl scripts than I am of html pages.

      Is this safe for a complete novice to attempt and what does "comment out" the existing line mean - is it just palce it in speach marks?

      Thanks

      Rob
      Rob
      For all your car, motorcycle and marine care, cleaning and detailing products.

      Comment


        #4
        Comment out (in Perl) means put a # charcter at the start of the line.

        So
        Code:
        		$::g_BillContact{'EMAIL'} !~ /\@/)			# and it is not in the expected format
        becomes
        Code:
        #		$::g_BillContact{'EMAIL'} !~ /\@/)			# and it is not in the expected format
        		$::g_BillContact{'EMAIL'} !~ /^([a-zA-Z0-9_'+*$%\^&!\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9:]{2,4})+$/)
        Make a backup of OrderScript.pl before proceeding and you should be safe.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment

        Working...
        X