Input validation with New-UDInputField

I am building a new input form, I am trying to run some basic validation on the input from the user. Following the documentation, I can make this work using New-UDInput with a param, similar to this:

New-UDInput -Endpoint {
param(
        [Parameter(Mandatory)]
        [ValidateLength(6,6)]
        [UniversalDashboard.ValidationErrorMessage("The employee id you entered is invalid.")]
        $EmployeeID
         )

However, this limits my options (at least I think) for some customization that would be needed like placeholder text. I would prefer to do validation on the New-UDInputField command instead of the entire input. I have tried putting the param right under the New-UDInputField, but can’t get it to work. Ideally something like this:

New-UDInput -Title "Password Reset" -SubmitText "Reset Password" -Content {
    New-UDInputField -Name "EmployeeID" -Placeholder "6 digit Employee ID" -Type "textbox"
       param(
       [Parameter(Mandatory)]
       [ValidateLength(6,6)]
       [UniversalDashboard.ValidationErrorMessage("The employee id you entered is invalid.")]
       $EmployeeID
       )

Does anyone know if this is possible? If no, do you know a way I can change the input field label, like -placeholder does in New-UDInputField?

I’m in the same boat. For now, I’m validating it with an if statement.

If ($employeeID -notmatch 'my_regex_pattern') {
    Show-UDToast -Message "This isn't valid"
    break
}

If you had a lot of validations, use a switch instead. It’s the best i could come up with for now.

I ended up ditching the New-UDInputField commands and just went back to param. I was able to get it working in an acceptable way doing it like this.

New-UDInput -SubmitText "Reset password" -Title "Password Reset" -Endpoint {
     param(
       [Parameter(Mandatory, HelpMessage = "6 digit Employee ID")]
       [ValidateLength(6, 6)]
       [ValidatePattern("^[0-9]*$")]
       [UniversalDashboard.ValidationErrorMessage("The employee id you entered is invalid.")]
      $EmployeeID,
1 Like

Sorry to bump this old thread but here we are over a year later - is there a way to validate New-UDInputField client side now?

I really need to be able to use either radio buttons or selects in my input forms.