How to personalize Password field based on strict Regular Expression (RegEx) formulas in Canvas PowerApps - CloudFronts

How to personalize Password field based on strict Regular Expression (RegEx) formulas in Canvas PowerApps

Hello,
In this blog, I’ll show you how to personalize Input Password field with various requirements using strict regular expression in Canvas PowerApp.

//Formula to show/hide Input field

//OnSelect of View-Icon.
UpdateContext({varShowPass: !varShowPass})
//Icon property of Icon-View
If(varShowPass, Icon.Hide, Icon.View)

//Mode for Input field
If(varShowPass, TextMode.SingleLine ,TextMode.Password)

Now, validation part comes in using RegEx.

Let’s say you have a requirement where,
1. Password length should be equal or greater than 8.
2. Password should contain at least 1 number.
3. Password should contain at least 1 lowercase alphabet.
4. Password should contain at least 1 uppercase alphabet.
5. Password should contain at least 1 special character.

After everything all requirements is satisfied, show that password is valid.

Let’s say you have 5 labels containing Text of these requirements and will be visible if its respective condition is not satisfied.

//Condition to validate requirement on Label's Visible property

//Length of Password should be equal or greater than 8
If(Len(TextInput1.Text) > 7, false, true)

//At least 1 number required
If(IsMatch(TextInput1.Text, ".*[0-9].*"), false, true)

//At least 1 lowercase alphabet required
If(IsMatch(TextInput1.Text, ".*[a-z].*"), false, true)

//At least 1 uppercase alphabet required
If(IsMatch(TextInput1.Text, ".*[A-Z].*"), false, true)

//At least 1 special character
If(IsMatch(TextInput1.Text, ".*[!@#$%^&*].*"), false, true)

//For Label representing "Password Valid" (Main Field Validation)
If(IsMatch(TextInput1.Text, "(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"), true, false)

Hope this helps you.


Share Story :

Secured By miniOrange