no empty values

Jun 26, 2013 at 12:16 PM
Edited Jun 26, 2013 at 12:17 PM

I'm trying to create a "Create AD User" script.
Is there any way to disallow empty fields?
Below is the code I'm working on, the task sounds simple enough, so I must be very noobish :-)
Function ShowUIWindow
$in = uniformgrid -ControlName "CreateADUser" -Columns 2 {
    textBox -Name "UserID"
    textBox -Name "FirstName"
    textBox -Name "LastName"
    textBox -Name "Password" Password123
    ComboBox -IsEditable:$false -SelectedIndex 0 -Name Afdeling @("Administrationsafd","Driftafdelingen")
    button -Content "Cancel" -IsCancel -On_Click {
        Get-ParentControl | Close-Control
    new-button "Ok" -IsDefault -On_Click {
        $parent | Set-UIValue -passThru | Close-Control
} -show
Jun 26, 2013 at 4:44 PM
Edited Jun 26, 2013 at 4:45 PM
Helps to think a little, sorry guys easy solve
button "Ok" -IsDefault -On_Click {
        if (!$UserID.value){
        New-Label "Ikke alle felter er udfyldt" -show }
        else {
        Get-ParentControl | Set-UIValue -passThru | Close-Control
Jun 26, 2013 at 5:03 PM
or so I thought.
it always evaluates to false it seems. I guess the value is not set at this point, so what to do?
Jun 26, 2013 at 11:21 PM
On a TextBox, the property you want is .Text not .Value