Page 1 of 1

enable button if $texbox not empty

Posted: Fri Dec 16, 2016 4: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 2419 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 5:33 am
by jvierra
Use the validation event to set that when the textbox is update.
  1. $textbox1_Validated={
  2.  
  3.     if($textbox1.Text){
  4.  
  5.         $button1.Enabled = $true
  6.  
  7.     }else{
  8.  
  9.         $button1.Enabled = $false
  10.  
  11.     }
  12.  
  13. }
You can also use the TextChanged event to do this.

Re: enable button if $texbox not empty

Posted: Sat Dec 17, 2016 12:55 am
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.