Jump to content
Sign in to follow this  

Multiple Input Validation

Recommended Posts


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

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.

Share this post

Link to post
Share on other sites

What about this

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

For $i=0 To UBound($inputs)-1
;~  GUICtrlSetBkColor(-1,0xff8080)
While 1
    Switch GUIGetMsg()
        Case -3
        Case $ok

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

Share this post

Link to post
Share on other sites

Very nice.

I've adapted it for my code and it's running beautifully now. :huh2:

Thank you ahmet!

Share this post

Link to post
Share on other sites

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.