So, i’m trying to validate a form, in teory when I hit the validar button, the widget calls checkcampos function, but always return is filled, even when it empty. If i change the if condition to == it return empty when is filled.
¿There is any other way to compare if nativetextfield is or not empty?
Thanks
Here’s the code:
local nombreinput = native.newTextField( centerX-131, _H-40, 250, 24 )
2.
nombreinput.align = “center”
3.
nombreinput.size = 18
4.
nombreinput:setTextColor( 1, 0.5, 0 )
5.
6.
7.
function checkcampos()
8.
if nombreinput ~= “” then
9.
--print(“Ready for scene change”)
10.
--storyboard.gotoScene( “scene1”, “slideUp”, 800 )
11.
native.showAlert(“test”, “the nombreinput field is filled.”)
12.
else
13.
native.showAlert(“test”, “the nombreinput field is empty.”)
14.
end
15.
end
16.
17.
local validar = widget.newButton
18.
{ width = 95,
19.
height = 65,
20.
y = _H + 137,
21.
x = centerX+205,
22.
id = “button6”,
23.
labelColor = { default={ 0, 0, 0 }, over={ 0, 0, 0, 0.5 } },
24.
label = “Validar Respuesta”, “Sansation”,
25.
onPress = checkcampos,
26.
fontSize = 12,
27.
textOnly=true
28.
}
29.
group:insert( validar )