How to use contains text for regular expressions

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.

The criteria are:

  • Have at least 8 characters
  • Have at least one uppercase letter
  • Have at least one lowercase letter
  • Have at least one number
  • Have at least one special character (like @#$%!)

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?

For this validator how do I do this?

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

It keeps giving the same error.

What are the paid and free extensions for Kodular?

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.

Same thing applies here as well.

Extensions?

Insted of empty text box add textbox1.text

Also

https://community.kodular.io/search?q=Password%20strength%20order

Quit surprise, last you had the same discussion and got solution i think at here.

2 Likes

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?

Instead of that empty box pls add this block foundbunder textbox1,

Textbox1.text

Add this block into that procedure event.

I did as they asked but the error must be in this contains text and I honestly don’t know how to make it work.

Yes

You can’t use the contains block like that
The easiest would be to use the previously mentioned extension
Taufun

1 Like

What extension?
As I said, I would like to do it this way. Which block can I compare, for example, in the word Bed if it contains capital letters?

This thread was marked as solved…

You will have to use for example a for each in list loop to find out if one of the characters in contained in your password

Taifun

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.