Guys, I’m using this simple password validator with regular expressions but it’s giving an error. No matter how many times I type the correct password, it always gives an error.
I have a question, when I type a value in the textbox field, this value goes to the variable in which the validation will be done. When I delete the text field, is there any value left inside this variable? If so, is there a way to clear it every time I delete what is inside the textbox?
Yes it will throw always error because you attempt expression logic in contains text block
We have alredy multiple extensions for this.
If you want to achieve this without extension, try like this
When Button1.Click
If (length of global password < 8)
Set Label1.Text to "❌ Password must be at least 8 characters!"
Else If (not contains any of "ABCDEFGHIJKLMNOPQRSTUVWXYZ" in global password)
Set Label1.Text to "❌ Must include an uppercase letter!"
Else If (not contains any of "abcdefghijklmnopqrstuvwxyz" in global password)
Set Label1.Text to "❌ Must include a lowercase letter!"
Else If (not contains any of "0123456789" in global password)
Set Label1.Text to "❌ Must include a number!"
Else If (not contains any of "@#$%!" in global password)
Set Label1.Text to "❌ Must include a special character (@#$%!)"
Else
Set Label1.Text to "✅ Valid password!"
When textbox1 text changed
Set global password to TextBox1.Text
So no worry about user clears the textbox, also it will be cleared from the global variable
You can achieve this without global variable
In the procedure use one local variable and set text text to it. Then call this variable into the procedure, simple. Or you can try without variable too
Your contains text piece logic is incorrect. You can not check the value contains piece as all the text at a time. Each character has to be checked in the value if is there using OR for each character. If it contains means the parameter is true else false.
And I found two password validators, but I wanted something more intuitive.
What would this text component contain any of be?
Can you show me what this block would look like?
I want to thank everyone who was willing to help me understand the code. It was a valuable experience. I will definitely use the extensions. That will conclude this post.