Is the TextInput Empty?

If you want to do any type of form validation in your app, you will need to make sure that you user has entered a username or a password for themselves.

There’s a dedicated text block to check whether a string of text is empty:

empty_text

Putting it together you would have something like this:

So, "if the text input is empty, do something"

2 Likes

Another way to do this is to measure the length of the input string, using the length of block.

The length of blockj returns a number of characters (including spaces) in a piece of text.

In this example, "if the text input contains 0 characters, do something"

1 Like

Finally, here are a couple of examples that don’t work as consistently.

When you first create your app the following won’t work:

And you will have to use the following instead.

However, if you are clearing the form you might do something like this:

In which case you will have to use the first option.

To avoid any unwanted behaviour in your app logic, please try to use the is empty or the length of approaches instead,

2 Likes