Very simple calculation method

This has worked perfectly for what I needed, is there a method that I can use where the a text field input is empty and if so then calls an event which shows an alert on screen like this…

[lua]

local function onComplete( event )

   if event.action == “clicked” then

        local i = event.index

        if i == 1 then

        end

    end

end

[/lua]

With my button function like this…

[lua]

local function btnNextHandler( event )

textboxResults.text = tonumber(textboxValue1.text) * tonumber(textboxValue2.text)

if 

textboxValue1.text == “” then

local alert = native.showAlert( “Warning”, “ERROR: No input in textbox(s)”, { “OK” }, onComplete)

end

[/lua]

But I keep getting an error saying 

Runtime error

error loading module ‘Page10.lua’ from file ‘c:\users\matt\documents\corona projects\hs app\Page10.lua’:

c:\users\matt\documents\corona projects\hs app\Page9.lua:195: ‘end’ expected (to close ‘function’ at line 26) near ‘<eof>’

stack traceback:

[C]: in function ‘error’

?: in function ‘gotoScene’

c:\users\matt\documents\corona projects\hs app\Page1.lua:12: in function ‘_onEvent’

?: in function ‘?’

?: in function <?:677>

?: in function <?:221>

Thanks again,

Matt.

I haven’t tested it but I think you just need a small adjustment to your button handler.

local function btnNextHandler ( event ) if textboxValue1.text == nil or textboxValue1.text == "" or textboxValue2.text == nil or textboxValue2.text == "" then local alert = native.showAlert( "Warning", "ERROR: No input in textbox(s)", { "OK" }, onComplete ) else textResult.text = tonumber(textboxValue1.text) \* tonumber(textboxValue2.text) end end

This worked perfectly.

Thanks,

Matt.