USING CONDITIONS FROM TEXT FIELDS

Hello to everybody!

I’m building my first “simple” application and I would need to do different actions depending on what is written in the text field.

for example, Let’s say that we have a text field called “Code:”, so I would like to build something like this:

if (txtCode == “1”) & (begin_button==pressed) then

   action 1

else

 action 2

end

Thank you very much!

Hi,

Maybe this will help you:

local my\_text\_field -- Init text field here local my\_button -- Init button and set your onEvent when you create the button local function onEvent( event ) if event.phase == "ended" then -- Button have been pressed if my\_text\_field.text == "something" then print("my\_text\_field.text is 'something'!") end end end

Documentation:

https://docs.coronalabs.com/api/library/widget/newButton.html

https://docs.coronalabs.com/api/library/native/newTextField.html

Best regards,

Tomas

Thanks bro! Best wishes!

Hi,

Maybe this will help you:

local my\_text\_field -- Init text field here local my\_button -- Init button and set your onEvent when you create the button local function onEvent( event ) if event.phase == "ended" then -- Button have been pressed if my\_text\_field.text == "something" then print("my\_text\_field.text is 'something'!") end end end

Documentation:

https://docs.coronalabs.com/api/library/widget/newButton.html

https://docs.coronalabs.com/api/library/native/newTextField.html

Best regards,

Tomas

Thanks bro! Best wishes!