Open
Description
Summary of the new feature / enhancement
As a user, I want to be able to type in my text box and have it validate while i type so that i cannot cause a condition where i can click a button when i am in an error state.
Here is an example of the contents of a new-udtablecolumn, if i have a text box in the column, and it validates with good, then my save button will be enabled, but then i go back and change my value to something that is bad, the button is still enabled, when i click the button, the validate happens AFTER i click the button, and thus saving bad data to my database.
New-UDTextbox -Id "uDTextbox$($eventdata.id)" -Value "" -OnChange {
$userInput = Get-UDElement -id "uDTextbox$($eventdataParent.id)" -Property Value
write-host "eventdata.gettype() on change: $($userInput.gettype()): $($userInput)"
} -OnValidate {
$userInput = Get-UDElement -id "uDTextbox$($eventdataParent.id)" -Property Value
write-host "eventdata.gettype() on validate: $($userInput.gettype()): $($userInput)"
# Validate the input format for 'hh:mm:ss' and '1d 2h 30m'
if ($userInput -match '^(?:(\d+)(?:\.(\d+))?:)?(\d+):(\d+):(\d+)$') {
# if TimeSpan is 'hh:mm:ss' format
Write-Host "Valid input format. for TimeSpan: 'hh:mm:ss'"
Set-UDElement -Id "uDButton$($eventdataParent.id)" -Properties @{Disabled = $false}
New-UDValidationResult -Valid
}
elseif ($userInput -match '^(\d+)d\s+(\d+)h\s+(\d+)m$') {
# if TimeSpan is '1d 2h 30m' format
Write-Host "Valid input format. for TimeSpan: '1d 2h 30m'"
Set-UDElement -Id "uDButton$($eventdataParent.id)" -Properties @{Disabled = $false}
New-UDValidationResult -Valid
}
elseif ($userInput -match '^(\d+)\s+day(?:s)?,\s+(\d+)\s+hour(?:s)?,\s+(\d+)\s+minute(?:s)?$') {
# if TimeSpan is '1 day, 2 hours, 30 minutes' format
Write-Host "Valid input format. for TimeSpan: '1 day, 2 hours, 30 minutes'"
Set-UDElement -Id "uDButton$($eventdataParent.id)" -Properties @{Disabled = $false}
New-UDValidationResult -Valid
}
else {
Write-Host "Invalid input format. Please try again."
Set-UDElement -Id "uDButton$($eventdataParent.id)" -Properties @{Disabled = $true}
New-UDValidationResult -ValidationError "Invalid input format. Please try again."
}
}
New-UDButton -Id "uDButton$($eventdata.id)" -Disabled -Icon (New-UDIcon -Icon save -Size 1x) -OnClick {
write-host "why did you let me click this?"
#Update-WhProductConfiguration -id $eventdataParent.id -caseCreationDelay (Get-UDElement -Id "udTextField$($eventdata.id)").value
}
Proposed technical implementation details (optional)
Maybe! i could do
-OnChange {
Set-udelement -id 'uDTextbox1' -TriggerEvent "OnValidate"
}