Jump to content

Recommended Posts

Posted

I have several input fields on my GUI and i want to validate them as a whole, not one by one.

All the input fields would be checked for their default value and then, the input fields that still have their default data would display a different color background and a message would display to tell the user to fill in the invalid input fields.

This is kind of what i'm trying to achieve:

Case $CriarCliente
            If GUICtrlRead($Name) = 'Name' Then
                GUICtrlSetBkColor($Name, 0xff8080);set background color if no new input
                ElseIf GUICtrlRead($Contact) = 'Contact' Then
                GUICtrlSetBkColor($Contact, 0xff8080);set background color if no new input
                MsgBox(4096+48, "", 'Missing Field'); show message only when ALL input fields are checked
            EndIf

Ofcourse in this example the background color will change after the first input is checked, and then after the second input is checked.

Is it possible to check all the inputs at once?

Could a 'Or' operator used within a 'If...Then' statement be used to solve this?

I'm completely lost.

Posted

What about this

Global $inputs[3], $inputs_default[3]=["Name","contact","Third"]

GUICreate("tesT")
For $i=0 To UBound($inputs)-1
    $inputs[$i]=GUICtrlCreateInput($inputs_default[$i],10,22+22*$i)
;~  GUICtrlSetBkColor(-1,0xff8080)
Next
$ok=GUICtrlCreateButton("Check",10,90)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            ExitLoop
        Case $ok
            _Check()
    EndSwitch
WEnd

Func _Check()
    For $i=0 To UBound($inputs)-1
        If GUICtrlRead($inputs[$i])=$inputs_default[$i] Then    GUICtrlSetBkColor($inputs[$i],0xff8080)
    Next
EndFunc

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...