Page 1 of 1

enable button if $texbox not empty

Posted: Fri Dec 16, 2016 3:07 am
by celma972
Dear All,

I cannot figure out how to enable a button when the $loginnametextbox is not empty. It stay disable.
Capture.PNG
Capture.PNG (21.8 KiB) Viewed 2984 times
Here i my code :

$loginametextbox.Text = $null

$formEnableUsersForm_Load={
#TODO: Initialize Form Controls here
$buttonOK.Enabled = $false
}

$buttonOK_Click={
#TODO: Place custom script here
$buttonOK.Enabled = $false

$loginametextbox.Text= {
$CheckInput
}

If ($CheckInput.text.trim() )
{
$buttonOK.Enabled = $true
}

}

Re: enable button if $texbox not empty

Posted: Fri Dec 16, 2016 4:33 am
by jvierra
Use the validation event to set that when the textbox is update.
  1. $textbox1_Validated={
  2.     if($textbox1.Text){
  3.         $button1.Enabled = $true
  4.     }else{
  5.         $button1.Enabled = $false
  6.     }
  7. }
You can also use the TextChanged event to do this.

Re: enable button if $texbox not empty

Posted: Fri Dec 16, 2016 11:55 pm
by localpct
On to J's point, textchanged event is great if you have a predetermined number of characters and you can eliminate the button if you choose.