Coding Challenge #2 - Live Input Feedback

Net Ninja · Beginner ·🌐 Frontend Engineering ·4y ago

Key Takeaways

This video demonstrates a coding challenge that focuses on providing live input feedback to users as they enter an email address, utilizing HTML, CSS, and JavaScript. The challenge requires creating a regular expression to detect valid email addresses, coloring the input border green when valid and gray when invalid, and animating a green tick icon next to the input field.

Full Transcript

all right then gang so welcome to your next coding challenge this one is also going to be a ux focused one which needs a little bit of html css and javascript knowledge so again if you don't know much about any of those things maybe try watching my courses on all three of those topics first of all the links to those are going to be down below the video anyway the challenge this time around is to offer some live feedback to a user as they enter an email into this input so whenever we detect that the value of the input is a valid email address we animate the green tick and also color the input border green too then when the value becomes invalid again we animate out the green tick and the border goes gray again so in this challenge there's three key things that you really need to focus on the first one is being able to detect whether the value inside the import is a valid email address whenever a user presses a key inside it and for that you're going to need to use a regular expression now i'm going to leave a link to a tutorial on my youtube channel all about how to make a regular expression for an email address so feel free to reference that to help you out the second thing you need to figure out is how to color the border of the input field when we have a valid email then change it back to gray when it's not valid again and the third thing you need to solve is how to animate in this tick icon next to the import when we have a valid email address and then animate it back out when it's not valid anymore so i think this challenge is going to combine a few different problems that you have to think about which is nice and by the way i don't want you to rely on the standard browser form validation by using the email type input and the required attribute for this problem because i want you to be able to think about how to solve it using your own logic and then offer your own live feedback to the user like this green tick right here now i'm going to start you off with a starter project which looks something like this it's just a form field on the page with no extra validation or anything like that and when we enter an email address into this we don't get any kind of live feedback to say that it's valid so your job is to take it from this point to the final product which is this that i just showed you so the starter project is on this repo on github coding challenges again the link is going to be down below and in order to get it you need to select from the branch drop down challenge to start and then you can download this project by clicking on the code button and then downloading a zip folder so once you've downloaded that folder you want to extract all so we can access the project folder and that should just take a second and then this is the folder right here we want to open up inside vs code so let's do that as well and here we go this is the starter project so let me just quickly walk you through this it's dead simple so first of all we have an index.html file and inside there we have a head and we have a link to this thing right here which is a google fonts and it's for material icons now the reason we're loading that in is so that we can use material icons down here to get the tick icon so if we want to use one of these icons then all we have to do is give something a class of material icons like so and then whatever the icon name is each icon has its own class and you can look that up by just googling google material icons all right so we load that in first of all then we have our own style sheet which we'll take a look at in a second and then a title now down here in the body dead simple we just have a form then we have a div with a class of field for the form field the field has a label right here that says enter your email then the input is a type of text and then a name of email and an id of email so remember i said don't use type email for this challenge because that's going to enable some browser validation when you submit a form now what i want you to do is practice your live validation so as a user is typing into the input field then we can kind of validate the email now you can use email and do that if you want to as well i just wanted to kind of make it clear that all of this validation logic is going to be your own all right so then after that we have this tick icon right here as well and then at the bottom we have this script linking to index.js so this is where all of your logic is going to live now inside index.css we just have some base styles right here so the body we give a background of a very light gray text align center font size 1.4 amps just to make things a bit bigger and a font family of vadana then the form itself we give a background of white a margin of 200 pixels top and bottom also left and right and then a padding of 20 pixels all the way around border radius of 10 pixels just to soften up the form box display is inline block and then after that we say form and the field inside that so this div right here we say displays flex so that each of these things sits next to each other all right left to right and then align items center all right then so after that we have the form input and we give that a margin of zero top and bottom 16 pixels left and right and that's just going to spread it out from this on the left and this on the right and then the border is two pixels solid and a gray color border radius four pixels just to soften the corners and then a padding of four pixels so that's all the base styles your solution styles can go down here now what i'd like to do is preview this in a browser and remember to do this i'm using the package live server which you can search for up here by typing live server like so and it's going to hopefully show up it's this package you need to install when you do that you can right click over here and we can open this up in a live server it's going to open in the browser for you and this is the starter project right so as you can see there's no validation in place and we'll just type in any old email address we always get the tick it's not going green so i want you to get from this to the end point which i showed you before and remember that looks something like this so to begin with the tip doesn't show but as i start to type in an email mario net ninja dot dev when it becomes valid we get that tick animating in this goes green and then when i start to delete and it's no longer a valid email address the tick goes away and the border goes great again so this is your end goal right here this is what you're aiming for so give this a good go and i'm going to post my solution tomorrow

Original Description

🐱‍💻 Access the course files on GitHub: https://github.com/iamshaunjp/Coding-Challenges 🐱‍💻 Modern JavaScript Course: On Net Ninja Pro - https://netninja.dev/p/modern-javascript-from-novice-to-ninja On YouTube - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc 🐱‍💻 HTML & CSS Crash Course: On Teachable - https://net-ninja-pro.teachable.com/p/html-css-crash-course On YouTube - https://www.youtube.com/watch?v=hu-q2zYwEYs&list=PL4cUxeGkcC9ivBf_eKCPIAYXWzLlPAm6G 🐱‍💻 VS Code - https://code.visualstudio.com/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

This coding challenge focuses on creating a live input feedback system for email validation using HTML, CSS, and JavaScript. The goal is to animate a green tick icon and color the input border green when a valid email address is entered, and gray when it's invalid.

Key Takeaways
  1. Create a regular expression to detect valid email addresses
  2. Add an event listener to the input field to detect changes
  3. Use JavaScript to animate the green tick icon and color the input border
  4. Style the input field and surrounding elements using CSS
  5. Test and refine the code to ensure it works as expected
💡 To create a live input feedback system, you need to combine JavaScript event listeners, regular expressions, and CSS styling to animate UI elements and provide instant feedback to users.

Related AI Lessons

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →