How to create a password validation input?

Hi Adam, Guys!
I’m creating a user creation form, but having a hard time to create the password validation.
My problem is: I want to add a password validation by typing it a second time and notifying user that the two password inputs match
How do I go about it?

Product: PowerShell Universal
Version: 1.4.6

Hi, @sanjosetour. There are, as with most anything PSU, a thousand ways to skin the proverbial cat. Here is an example of just one way to do it: provide the user a text box, and then a pop-up (Modal) to confirm. Then provide feedback on whether the passwords match via a Toast message:

New-UDDashboard -Title "Password Checker" -Content {
New-UDTextbox -Id "Passwd1" -Label "Password" -Type password

New-UDButton -OnClick {
    Show-UDModal -Persistent -Content {
        New-UDTextbox -Id "Passwd2" -Label "Retype Password" -Type password
    } -Footer {
        New-UDButton -Text "Submit" -OnClick {
            If ((Get-UDElement -Id "Passwd1").value -eq (Get-UDElement -Id "Passwd2").value) {
                Show-UDToast -Message "Passwords Match!" -Duration 2000
            } else {
                Show-UDToast -Message "Sorry, passwords do not match!" -Duration 2000
                Show-UDToast -Message "Password1: $((Get-UDElement -Id 'Passwd1').value)" -Duration 3000
                Show-UDToast -Message "Password2: $((Get-UDElement -Id 'Passwd2').value)" -Duration 3000
            }
            Hide-UDModal                
        }
    }
  } -Text "Test Password"
}

Feel free to ask if you have questions.

1 Like