# Email Error Handling

**URL:** <https://community.thunkable.com/t/email-error-handling/2651034>\
**Category:** Tutorials and DIY Guides\
**Tags:** community, auth, tips\
**Created:** [October 18, 2023, 1:55pm UTC](https://community.thunkable.com/t/email-error-handling/2651034 "2023-10-18T13:55:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jahaan](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jahaan](https://community.thunkable.com/u/jahaan)\
**Post date:** [October 18, 2023, 1:55pm UTC](https://community.thunkable.com/t/email-error-handling/2651034/1 "2023-10-18T13:55:38Z")

</div>

Hello! Today I’ll show you how to do some basic error handling for an email input. It’s fairly simple and can be used in any app that utilizes email sign in.

**1: Build your UI**

I was building a passwordless sign-in system for an app I was making, so I thought I’d walk you through the email error handling part.

All you really need is an **input component** and **submit button** , but I have a few extra components.

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/4/14724d5ba5a417afafb4cce60b6e92597549cc1d.png)

**2: Blocks**

This part is fairly easy but uses a lot of code, so I’ll break it down into smaller parts.

But first, add an alert component in the _blocks_ area. Name and title it “Error”. Change the “Confirm” button to “Okay” and remove the “Cancel” button. Don’t give it a message yet.

**Part 1:**

Drag a “when (submit button) is clicked” block onto your interface.

In this part, we’ll run 3 tests using 3 dynamically initialized variables and some list blocks:

Test 1 checks for any spaces in the email by breaking the text provided from the input into a list, with the delimiter " ".

Test 2 checks for either no “@” or more than one “@” symbol in the email by breaking the text provided from the input into a list, with the delimiter “@”.

Test 3 checks for either no “.” or more than one “.” in the email by breaking the text provided from the input into a list, with the delimiter “.”.

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/0/30775701c6a876ab43c5ab28f6dc6157ca354fa1.png)

**The downside to this method is, since there are so many ending domains (.com, etc.) we can’t test for that. We also can’t test for a valid service provider. But even without these features, it is pretty good for what it does.**

**Part 2:**

Let’s put these tests to use with some _if_ blocks.

Read this carefully, as things can get messy fast with these blocks.

Add an if block with 3 _else if_ conditions.

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/a/0ad0f4dd2025415748feed20220a938c25e9b399.png)

In the first _if_, we’ll use a basic text _is empty_ block and call an alert’s show with a custom message:

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/5/756856f2e580aaa553866e3ffa29beda2658e750.png)

For the second one:

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/b/2b3de73e4cc48ae8f4ed26d1c9e7cb2841d42fb1.png)

**EDIT: VALUE SHOULD BE “\>2” AND “\<2”, NOT “\>1” AND “\<1” FOR CONDITIONS 3 AND 4, SORRY FOR MY MISTAKE**

For the third one:

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f1b9d82ca8f9bd8021c3b621ee8db71ae684dead.png)

For the fourth one:

**EDIT: SECOND VALUE SHOULD NOT BE “test2”, IT SHOULD BE “test3”**

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/7/b79182564da13eb40b68ff6cf05ed9bb2558fa91.png)

**I’ve already explained the logic and the _do_ blocks previously in this article.**

Finally, we’ll create an _else_ condition:

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/6/c6b4aad42e437dfa9b4d8b072747f23cb8700441.png)

Here, you can choose what happens if the email is correct. Since I’m building a passwordless sign-in system, my app will use an API to send an email to the email address provided, but what you’ll do is relevant to _your_ app.

**And you’re done!** Let me know if you want a tutorial on a full passwordless sign-in system in the near future. Hope this helped you!

Edit:  
Hey guys! There was a bug where I wasn’t getting the desired output for the “@” and “.” during testing. I realized that it’s a small little detail and a simple fix.

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a2206cde20866d714f5efed06df469c30f0bece2.png)

You want to make sure the order of the values are “\<” “\>” instead of “\>” “\<” or it won’t work.

Happy Thunking!

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [October 18, 2023, 2:14pm UTC](https://community.thunkable.com/t/email-error-handling/2651034/2 "2023-10-18T14:14:16Z")

</div>

Nice tutorial! Thanks for posting.

---

<div class="post-metadata">

**Author:** ![jahaan](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jahaan](https://community.thunkable.com/u/jahaan)\
**Post date:** [October 18, 2023, 2:18pm UTC](https://community.thunkable.com/t/email-error-handling/2651034/5 "2023-10-18T14:18:41Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![jahaan](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jahaan](https://community.thunkable.com/u/jahaan)\
**Post date:** [October 18, 2023, 2:20pm UTC](https://community.thunkable.com/t/email-error-handling/2651034/6 "2023-10-18T14:20:26Z")

</div>

Hey guys! There was a bug where I wasn’t getting the desired output for the “@” and “.” during testing. I realized that it’s a small little detail and a simple fix.

 ![screenshot](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/2/a2206cde20866d714f5efed06df469c30f0bece2.png)

You want to make sure the order of the values are “\<” “\>” instead of “\>” “\<” or it won’t work.

Happy Thunking!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:33pm UTC](https://community.thunkable.com/t/email-error-handling/2651034/7 "2024-11-08T13:33:24Z")

</div>


