LonelyRoad Posted August 3, 2013 Posted August 3, 2013 I am trying to validate an email address passed to a function (as shown in the code below) but no matter what I give the function it always returns no match (and the outputchatbox runs twice for some reason). function validateEmail(email) local email = tostring(email) if (email:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then outputChatBox("Match!") return true else outputChatBox("No Match!") return false end end addCommandHandler("testing", validateEmail)
denny199 Posted August 3, 2013 Posted August 3, 2013 The first parameter of addCommandHandler is "commandname" for the client side and "playersource" for server side, so use for server side in your function: validateEmail(_,_,email) and for the client: validateEmail(_,email)
LonelyRoad Posted August 3, 2013 Author Posted August 3, 2013 For what reason would the 'No Match!' output twice here now? If the email matches, it returns true and does the outputchatbox once, but if it's no match it does the outputchatbox twice (and presumably returns false twice, too).
denny199 Posted August 3, 2013 Posted August 3, 2013 Debug the script, chek what email returns, and the email:match
LonelyRoad Posted August 3, 2013 Author Posted August 3, 2013 The :match() part I found on the Lua Docs, I was hoping a copy+paste with a little bit of tweaking would work.
bandi94 Posted August 3, 2013 Posted August 3, 2013 I just tryed it client side. With the command handler , "/testing [email protected]" - return one time match in the chatbox. "/testing asd@yahoo" - return one time no match in the chatbox. so the function work's well maybe the problem is somewhere else ? you tested it aswell with the CommandHandler ??
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now