How to make a vaildation for a form

Hey guys i went through the entire build process without thinking to place a validation via js.
Is there a simple way to approach this? Maybe a simple validation that detects something is missing and makes a general error at the bottom of the UI? Any recommended resources? or ideas?

A couple things go into this.

If you’re talking about making sure that the email address input is formatted like an email address and so on, then HTML actually has some built in stuff for that. You can set the type to email, for example. You can also add a required property.

Maybe not in this form, but others you might want to add some of your own rules. A value must be unique, for example. Or a password must contain a number. Then you would write your own validation functions to check the value of an input and update the dom accordingly.

Finally, you typically want to prevent submitting an invalid form. You can choose to either disable the submit button if any field is invalid or to do a check before completing the submit action.

Wow! Awesome! Any ideas for js?

You would probably want to define an error class that could be applied to form elements. Either when a form element loses focus, or someone clicks the submit button (or both) you want to use your dom manipulation tools to get the value from the form, test it, and add that error class. When you write your own validation functions I recommend returning a boolean.

For example:

when submit pushed
   for each field - if invalid, add error class
   if any field invalid - display message
       else do submit action