login
March 29, 2024, 01:11:34 pm

Author Topic: [SNIPPET] Email verification  (Read 1523 times)

0 Members and 1 Guest are viewing this topic.

MaDKilleR

  • Vice Underdog
  • Crazy Man
  • *
  • Posts: 1517
  • Country: ca
  • Hi.
    • View Profile
    • MaDKiLLeR's Site
[SNIPPET] Email verification
« on: June 13, 2013, 09:56:01 am »
Not much, but a simple script to verify whether the provided email address is valid or not. This script can be useful when you're storing emails of your players, for whatever purpose. You can point out the invalid emails and prompt the user to enter a valid one.

Valid emails
  • person@domain.com
  • person@sub.domain.com

Invalid emails
  • all the random idiotic ones.

Source Code

Code: [Select]
function verifyEmail( email ) {

      if ( email.find( "@" ) == null && email.find( "." ) == null ) return 0;
  else
  {
      local domain, sep = split( email, "@" );
  if ( sep.len() == 2 ) {

        domain = split( sep[1], "." );
        if ( domain.len() > 1 ) {

local length = domain.len() == 2 ? domain[1].len() : domain[2].len();
if ( length > 1 ) return 1;
else return 0;

}
else return 0;
  }
                  else return 0;    
         }
}

Example


Funny Funny x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

- [VU]MaDKiLLeR

HeLLHounD

  • Crazy Man
  • *****
  • Posts: 1333
  • Country: be
  • 666
    • View Profile
Re: [SNIPPET] Email verification
« Reply #1 on: June 16, 2013, 09:31:53 pm »
nice job :thumbsup:
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


WiLsOn

  • Crazy Man
  • *****
  • *
  • *
  • *
  • Posts: 5488
  • Country: 00
  • First in battle last in retreat.
    • View Profile
Re: [SNIPPET] Email verification
« Reply #2 on: June 16, 2013, 09:35:37 pm »
As always  :thumbsup: nice work.  :)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor