Show input when searchbox's value is valid

basically, i’m trying to get it so a user can search for their appropriate school.

when they either press ENTER or click the search icon it will show the e-mail and password inputs ONLY if the school they entered is actually on the database.

if that makes sense?

anybody able to help? cheers

1 Like

The content of the SearchBox element is handily split up in two different types of conditions that might help you out here:

  • If the user has typed something, but it didn’t produce any result, the content of the SearchBox is contained within the typed text
  • If the user did find and select a result, the the content is stored as the SearchBox’s value

In other words, if the user typed something, but didn’t find or select it, the value will be empty. You can use this to set up the right conditions to show or hide the other fields.

Hope that made sense!

1 Like

Hello @petter, so I have another example which might help me understand better.

User searches for a student, then clicks the search button and it opens a pop-up. this should only occur if the search box’s value is actually a student

only when SearchBoxA’s value is …?

When you set up the SearchBox element, you specify what kind of data it should be searching for (I’ assuming you know this step, but let me know if it’s unclear). In your case, I’m guessing you’ve set it to Do a Search for the data type Student.

As your users type a text into the search box, the letters that are typed are the SearchBox’s typed text. Bubble uses the typed text data to try and match it with the data field you specified under Field to search.

As the user types, a dropdown shows up with relevant results (provided there are relevant results), and the user can pick the correct one. Now, two things happen when the user actually goes from searching to selecting a result:

  • the typed text field of the Searchbox element becomes empty
  • the value field of the Searchbox element becomes the Student that the user picked

So, what you wanted to know is how we can tell if the user has actually found/selected a Student in the Searchbox? Since we know that when a SearchBox has a result, the value field will not be empty, we can se that as a Condition.

Here’s what that condition would look like on the element itself, and the same logic can be applied to a workflow:

Thank you!