Skip to content

Instantly share code, notes, and snippets.


Chris Padilla cdpadilla42

View GitHub Profile
cdpadilla42 /
Last active July 17, 2020 17:33
surefoot Code Challenges

Form Validation

Adding client side validation to surefoot's engineer contact form.

The attached script is used to add further validation to the form. The validation keeps responses quick by working in the browser before sending any data to the servers.

The code listens for the user to hit submit on the form. Once done, the script will check the message and name fields to see if there is any text written. If not, the code will add a red error message directly below the erroneous field. Otherwise, the form submits successfully.

This function can be added by copying and pasting the entire code snippet into the html document, one line directly above the tag.