Email address validation using corona sdk

两盒软妹~` 提交于 2019-12-10 19:19:05

问题


In my project, a form for the user to fill the details. In that, one text field to enter email id of the user. So i need to validate the email in that text field, in corona project


回答1:


Try this regular expression:

local email = "email@email.com"
if (email:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
    print("VALID EMAIL")
else
    print("INVALID EMAIL")                
end



回答2:


Use regular expression pattern for checking email.

Use this "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?"




回答3:


Try this:

local pattern = "[%w][%p][@][%w]+[.][%w.]+[^.]+"

return value ~= nil and #value >= 1 and #value <= 63 and istring.is_ascii(value) and not not value:match(pattern) and #value:match(pattern) == #value

Ex: email@email.com email@email.com.br



来源:https://stackoverflow.com/questions/21040325/email-address-validation-using-corona-sdk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!