Page 1 of 1

Make a text box mandatory

Posted: Thu Nov 08, 2018 2:38 pm
by Chris.Ediger
I would like to make a text box in my script mandatory. As in the "OK" button will not work unless the box has something in it.

Re: Make a text box mandatory

Posted: Thu Nov 08, 2018 2:51 pm
by Alexander Riedel
[Topic moved by moderator]

Re: Make a text box mandatory

Posted: Thu Nov 08, 2018 3:18 pm
by Chris.Ediger
Can you maybe tell me where you moved this post?

Re: Make a text box mandatory

Posted: Thu Nov 08, 2018 3:20 pm
by Alexander Riedel
Right here where you answered it :D In the PowerShell GUI forum.

Re: Make a text box mandatory

Posted: Thu Nov 08, 2018 4:25 pm
by jvierra
Here is a good place to start to learn how to validate a form based on its contents. There are a number of techniques described and some very good examples.

https://info.sapien.com/index.php/guis/gui-advanced-tips/validating-the-form

Since you are new to forms I recommend reading some of the other articles listed in the left menu. They will help you get up to speed with forms fairly quickly.

The simple answer to your question is to use the textbox "Validating" event to cancel the button event. The exact method of validation is a design choice which depends on the form design you are using.