Bootcamps

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Academy

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Full-Stack Software Developer - 16w

Data Science and Machine Learning - 16 wks

Search from all Lessons


LoginGet Started

Register to 4Geeks

← Back to Projects

Use JS to validate an HTML Form

Difficulty

  • easy

Average duration

4 hrs

Technologies

Difficulty

  • easy

Average duration

4 hrs

Technologies

Weekly Coding Challenge

Every week, we pick a real-life project to build your portfolio and get ready for a job. All projects are built with ChatGPT as co-pilot!

Start the Challenge

Podcast: Code Sets You Free

A tech-culture podcast where you learn to fight the enemies that blocks your way to become a successful professional in tech.

Listen the podcast

HTML5 Form Validations

After building the HTML and CSS for this form, we need to make sure it prevents the user from submitting a form with the wrong information or format, in web development we call that: Form Validations, you can read more here

To prevent a form submission, we have to listen to the "submit" event that is triggered by the form itself when the user presses either: the enter/return key or the submit button.

Here is a little more about preventing an event from occurring: https://www.youtube.com/watch?v=I_fVO_NzT2g&t=401s

Form Validations Preview

🌱 How to start this project

Do not clone this repository.

The first step to start coding is cloning the vanillajs boilerplate on your local computer or opening it using gitpod.

a) If using Gitpod you can clone the boilerplate by clicking here.

b) If working locally type the following command from your command line: $ git clone https://github.com/4GeeksAcademy/vanillajs-hello.

💡 Important: Remember to create a new repository, update the remote (git remote set-url origin <your new url>), and upload the code to your new repository using add, commit and push.

Instructions

After the user submits the form:

  1. Make sure to stop the flow of the submission using preventDefault(), here is a little bit more about preventDefault().
  2. After preventing the submission, make sure all the input values are correct and properly formatted.
  3. If there are one or more inputs with an invalid value, show a clear error on the top of the form with a very explicit message about what happened.
  4. Change the background color of the relevant inputs (the ones with incorrect data).

What to do if you are stuck?

Don't get frustrated and ask for help! After trying on your own for 20 min, it is time to stop working and ask for help.

🤠 Feeling Confident?

This additional requirement is not mandatory to complete the project:

Make the form errors show on top of each input instead of on the top of the form, that way the user will understand faster what the problem is about.

Signup and get access to similar projects

We will use it to give you access to your account.
Already have an account? Login here.

Difficulty

  • easy

Average duration

4 hrs

Technologies

Difficulty

  • easy

Average duration

4 hrs

Technologies

Difficulty

  • easy

Average duration

4 hrs

Technologies

Difficulty

  • easy

Average duration

4 hrs

Technologies

Signup and get access to similar projects

We will use it to give you access to your account.
Already have an account? Login here.

Difficulty

  • easy

Average duration

4 hrs

Technologies

Difficulty

  • easy

Average duration

4 hrs

Technologies

Weekly Coding Challenge

Every week, we pick a real-life project to build your portfolio and get ready for a job. All projects are built with ChatGPT as co-pilot!

Start the Challenge

Podcast: Code Sets You Free

A tech-culture podcast where you learn to fight the enemies that blocks your way to become a successful professional in tech.

Listen the podcast