pintas Posted June 11, 2011 Share Posted June 11, 2011 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. Link to comment Share on other sites More sharing options...
ahmet Posted June 11, 2011 Share Posted June 11, 2011 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 Link to comment Share on other sites More sharing options...
pintas Posted June 11, 2011 Author Share Posted June 11, 2011 Very nice. I've adapted it for my code and it's running beautifully now. Thank you ahmet! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now