# Create a code validation page like Stripe or Paypal

**URL:** <https://forum.bubble.io/t/create-a-code-validation-page-like-stripe-or-paypal/314842>\
**Category:** Tips\
**Created:** [March 28, 2024, 7:43am UTC](https://forum.bubble.io/t/create-a-code-validation-page-like-stripe-or-paypal/314842 "2024-03-28T07:43:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lydia.provin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lydia.provin/32/88468_2.png) [@lydia.provin](https://forum.bubble.io/u/lydia.provin)\
**Post date:** [March 28, 2024, 7:43am UTC](https://forum.bubble.io/t/create-a-code-validation-page-like-stripe-or-paypal/314842/1 "2024-03-28T07:43:43Z")

</div>

Hi,

For one of my applications, I created an e-mail validation system after registration. Users who have just registered receive an e-mail containing a 4-digit code which they must enter on the confirmation page. Without this, they can’t use the application. It’s the same thing you see when you want to connect to your Stripe or Paypal account, for example.  
 ![1](https://us1.discourse-cdn.com/bubble/original/3X/8/0/8004e7ab2f08a8b5e626ef531d64d973b7929b3f.png)

It’s simple, but I thought it might be useful for other users. So here’s what I’ve done.

**Creation of fields in the Users data type**  
I created a text field named _Code pour confirmation_ (Code for confirmation). A text field in case the generated code starts with zero.  
I’ve also created a boolean field called _E-mail vérifié_ (Verified e-mail), which defaults to “no”.

**Creation of the registration popup**  
For registration, I’ve created a simple popup with First name, Nickname, E-mail and Password:  
 ![2](https://us1.discourse-cdn.com/bubble/original/3X/0/2/02cdeea7769b355df868103450f837d1ac8dc349.jpeg)

When the user clicks on _Je m’inscris_ (I’m registering), I use the _Sign the user up_ action with, among the fields filled in when adding the user, the _Code pour confirmation_ field. I use the Data sources named _Calculate formula_ of type _Generate random string_. I set _Length of characters_ to 4 and only check _Use numbers_:  
 ![3](https://us1.discourse-cdn.com/bubble/original/3X/7/1/710bc95ba0e2de6e162c5968bfdea43617907a0a.jpeg)

After this action, I send an e-mail containing the code with `Current User’s Code pour confirmation`.

I’ve also created a reusable popup that appears on every page of the website where the user needs to be logged in. It only appears if the _E-mail vérifié_ field is set to no, to tell the user that he needs to validate his e-mail with the code received (with a button to redirect him to the page):  
 ![4](https://us1.discourse-cdn.com/bubble/original/3X/9/9/995733ab5761fd118538450247bedd5fe52caa20.jpeg)

**Creation of the confirmation page**

1. I’ve created a page called _Confirmation_ with 4 inputs whose _Content format_ is _Text_, the number of characters is limited to _1_ and the field must not be empty.

2. To ensure that the user can only enter numbers, I use the [Input Mask plugin](https://bubble.io/plugin/input-mask-1609444246883x924984661248573400). I therefore place 4 Mask Input elements in a group on the page. For the _Id Attribute Input_, I put _Code1_ for the first one, _Code2_ for the second, and so on. For _Mask field_, I’ve set _0_ to allow only one number:  

If you haven’t already done, check the _Expose the option to add an ID attribute to HTML elements_ box at the bottom of the _General_ tab on the _Settings_ page. Then, on each input, you need to transfer the name given in each Mask input. So for the first input, the _ID Attribute_ is _Code1_, for the second _Code2_ and so on:

 ![7](https://us1.discourse-cdn.com/bubble/original/3X/3/a/3a9e1345f900d8af5d0a8ddbd465510ae5aa1cff.jpeg)

1. I then created an input named _Input Concatenation_ whose _Initial content_ is `Input Code1's value append Input Code2's value append Input Code3's value append Input Code4's value`, again with _Content format_ set to _Text_.

2. Finally, for the first 3 inputs, I’ve set a _Do when condition is true_ workflow to _Every time_, where the condition for the first is `Input Code 1's value is not empty` and the action is _Set focus_ on Element _Input Code2_, so that each time a digit is entered, the cursor moves on to the next input. I’ve done the same for the 2nd and 3rd inputs, but not the 4th, since you can’t set focus on a button:  

_ **Buttons** _

1. I’ve created a button called _Je confirme mon adresse e-mail_ (I confirm my e-mail address) with a condition: `When Input Concatenation's value is empty or Current User is logged out` (for this second part of the condition, I display a red text if the user isn’t logged in, telling him to do so in order to validate), then the element is not clickable.  
On clicking this button, 2 workflows are possible:

- `Current User's Code pour confirmation is Input Concatenation's value` (the code is correct) then I modify the user to empty the _Code pour confirmation_ field and change the _E-mail vérifié_ field to “yes”, I warn the user that his e-mail is validated (with the [myAlerts! plugin](https://bubble.io/plugin/myalerts-1529535510382x166541069778419700)) and I redirect him to the Dashboard page:  

- `Current User's Code pour confirmation is not Input Concatenation's value` (the code is incorrect), I simply warn the user that the code is not correct:  

1. I’ve created another button called _Je veux recevoir un nouveau code_ (I want to receive a new code), whose workflow acts in the same way as at registration, i.e. _Make changes to current user_ (to generate a new code) and _Send email_ (to resend the regenerated code):  
 ![11](https://us1.discourse-cdn.com/bubble/original/3X/a/7/a7569d7639592d8d729b2f464b4c675383d0f7e4.jpeg)

The procedure is the same if you want to use more digits for the code.

However, I haven’t found a solution if you copy-paste the code into the first input so that it sticks each digit into the others. If anyone has a solution 😉

Hope this helps 😊

---

<div class="post-metadata">

**Author:** ![nico.dicagno](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nico.dicagno/32/207961_2.png) [@nico.dicagno](https://forum.bubble.io/u/nico.dicagno)\
**Post date:** [March 28, 2024, 3:21pm UTC](https://forum.bubble.io/t/create-a-code-validation-page-like-stripe-or-paypal/314842/2 "2024-03-28T15:21:16Z")

</div>

Great guide and write up!

> [@lydia.provin](#):
>
> When the user clicks on _Je m’inscris_ (I’m registering), I use the _Sign the user up_ action with, among the fields filled in when adding the user, the _Code pour confirmation_ field. I use the Data sources named _Calculate formula_ of type _Generate random string_. I set _Length of characters_ to 4 and only check _Use numbers_:

Just as a heads up, if you generate this random code on a page-level workflow, it will be visible to the user if they inspect the page! You can argue that people generally won’t know how to, but its the tech-savvy people who can/will exploit all your app’s vulnerabilities. It would be advisable to create a backend API workflow which generates the code and sends the email. Trigger the backend workflow from the page so that the code is generated on the server rather than on the client.

> [@lydia.provin](#):
>
> However, I haven’t found a solution if you copy-paste the code into the first input so that it sticks each digit into the others. If anyone has a solution 😉

This could get you on the right direction. The trick is using multiple elements instead of trying to do everything on one.

> [@Input format (\_ \_ \_ \_)](https://forum.bubble.io/t/input-format/305701/4):
>
> There might be an easier way, but this is how i like doing it: Don’t display the '\_ \_ \_ ’ using the input itself; use separate visual elements Set the font color of the input to invisible. (This input is where users type, but they wont be able to actually see it) Layered under of the Input\*, place as many text elements as number of characters in your code. These text elements would display ‘\_’, but use a conditional that checks whether ‘Input: extract with regex: (regex pattern= . (a single…

---

<div class="post-metadata">

**Author:** ![lydia.provin](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lydia.provin/32/88468_2.png) [@lydia.provin](https://forum.bubble.io/u/lydia.provin)\
**Post date:** [March 28, 2024, 4:10pm UTC](https://forum.bubble.io/t/create-a-code-validation-page-like-stripe-or-paypal/314842/3 "2024-03-28T16:10:57Z")

</div>

Thank you 😊  
And thanks for your advice! I might do a version 2 of this tutorial 😉
