I have an input field and I want to allow users to leave it blank. I expected that the value of the variable to be $null
when I validated it, but it wasn’t. Then I expected it to be an empty string ""
, but it was sometimes and not other times, quite confusingly. Apparently, the code below returns a string with the text value of “null
” if the field has never been touched, but if it was typed into and then deleted before submitting, it returns a value of an empty string ""
. At the very least, this inconsistent behavior is a bug, I think, but honestly, I wish, regardless, they returned with a value of $null
. Thoughts?
$Content = {New-UDDashboard -Content {
New-UDInput -Title "Output Options" -SubmitText "Search!" -Content {
New-UDInputField -Name AdditionalEmail -Type textbox -Placeholder "List of additional email addresses to send to."
} -Endpoint {
param($AdditionalEmail)
if ($AdditionalEmail -eq $null) {New-UDInputAction -Toast "The value of Additional Email is: `$null" -Duration 5000}
else {New-UDInputAction -Toast "Additional Email is of type: $($AdditionalEmail.gettype())" -Duration 5000}
if ($AdditionalEmail -eq "") {New-UDInputAction -Toast "The value of Additional Email is: Empty String" -Duration 5000}
if ($AdditionalEmail -eq "null") {New-UDInputAction -Toast "The value of Additional Email is: `"null`"" -Duration 5000}
}
}}
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Content $Content -Port 10000