Input Field Validation by regex

Hello, I can’t seem to find how to validate an input field.

For example I need that the text entered in an input fields matches exactly ASB-2023 where ASB could be any uppercase letter and 2023 any 4 digit number. I’m use to deal easily with this using regex but I don’t see a viable way with Bubble.

Thank you,

Hey @hairo,

You can use regex extraction on the input field like in these examples:

Turn the input background red if the test fails:

Or turn it green if it is a match:

You just evaluate the count of items that comes back from the regex extract – zero means it failed, 1 means a match.

Here’s the regex for easier copy/paste to Bubble (note my original screenshots had an erroneous comma after the 4):
^[A-Z]{3}-[0-9]{4}$



Looking to improve your Bubble™ skills?

Let me turn
:thinking: :tired_face: :confounded:

into
:grinning: :sunglasses: :woman_student:

Coaching and Development at https://uniqueideas.com or schedule a free intro session :gift:

Ken Truesdale
LinkedIn

1 Like

Thanks @mebeingken, this could definitely work :+1:. I can reach a visual validation but still the user would be able to submit a wrong pattern.

This condition can be used in many places…like on a button click event before saving data, etc.

This would only perform the actions within this workflow if the input is valid.

2 Likes

Great @mebeingken. I think I got it to work with this last tip. Also I added a parallel workflow to show user feedback when wrong pattern.

Thanks again!

1 Like