Should i do something like this if i want a "Submit Button" to check Answers?

Hi guys. Good Day.

I’m trying to create a “Submit Button” in which after inputting an answer in a game, the player will use the submit button to ‘Submit’ the answer. And here is the moment in which the submit button will check if the answer is correct or not.

Here is my code for the button:

    local SubmitButton = widget.newButton
    {
    width = 250,
    height = 70,
    top = 605,
    left = 925,
    defaultFile = “Buttons/SubmitButtonOn.png”,
    overFile = “Buttons/SubmitButtonOff.png”,
    onEvent = SubmitButtonEvent,
    }

And this is for my ButtonEvent:

local function SubmitButtonEvent( event )
        local phase = event.phase

            if event.phase = “began” then
                local function checkAns()
                local str = “”
                local count = 0

            for i = 1 , rowMax do
                if name[i] then
                    str = str…name[i]
                    count = count + 1
                end
               end            
          
        if str == answer then
            local gameComp = true

            for k, v in pairs(myData.categories) do
                print(“Check”,v.isCompleted)
                if not v.isCompleted then
                gameComp = false
            end
        end

        print(“gameComp”,gameComp)
        end
    end

end

I really don’t know what to do for this kind of button, I’m sorry if i have so many mistake. What should i do?