Email Validation

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
jwtea
Posts: 59
Joined: Fri Mar 23, 2018 2:01 am

Email Validation

Post by jwtea » Wed May 09, 2018 2:46 am

Hello,

Do anyone know what's the code for email validation in a field??

MaxV
Posts: 1499
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Email Validation

Post by MaxV » Tue May 15, 2018 1:01 am

I use this:

Code: Select all

#we need to test tEmail
put "((?i)(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|§(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*§)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))" into regemail 
replace "§" with quote in regemail #now regemail is the correct regula espression
put matchtext(temail,regemail,controllo) into temp
if controllo is not temail then
   answer temail " is not a valid email address"
end if
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

jwtea
Posts: 59
Joined: Fri Mar 23, 2018 2:01 am

Re: Email Validation

Post by jwtea » Tue May 15, 2018 10:34 am

Hello MaxV,

sorry i'm abit blur :roll:

My field name is call "emailfield".

My button script is to check the validation of the email ~
How should i put this code into my button script??

Thanks!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5394
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Email Validation

Post by dunbarx » Tue May 15, 2018 2:42 pm

Hi.
sorry i'm abit blur
This will throw an error. It should be:

Code: Select all

sorry i'm a bit ablur
:D

Craig

jwtea
Posts: 59
Joined: Fri Mar 23, 2018 2:01 am

Re: Email Validation

Post by jwtea » Wed May 16, 2018 2:22 am

Hello, thanks all! I managed to get it ~ ~
Appreciate all your help 8)

Code: Select all

on mouseup
   
   put fld "email" into temail
   
put "((?i)(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|§(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*§)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))" into regemail 
   replace "§" with quote in regemail #now regemail is the correct regula espression
   put matchtext(temail,regemail,validate) into temp
  
 if validate is not temail then
      answer " is not a valid email address"
   else
      answer "is email"
   end if
   
end mouseup

Post Reply

Return to “Talking LiveCode”