{"id":10949,"date":"2020-06-23T22:32:21","date_gmt":"2020-06-24T02:32:21","guid":{"rendered":"https:\/\/www.carnaghan.com\/?p=10949"},"modified":"2020-06-23T23:13:08","modified_gmt":"2020-06-24T03:13:08","slug":"creating-a-super-simple-javascript-validated-form","status":"publish","type":"post","link":"https:\/\/www.carnaghan.com\/creating-a-super-simple-javascript-validated-form\/","title":{"rendered":"Creating a Super Simple JavaScript Validated Form"},"content":{"rendered":"\n

There are times when you need to create a basic HTML form that provides validation to end users. Without leveraging a framework or additional libraries, this can be easily achieved by using JavaScript directly. This article walks through the basic steps of creating a simple validated form using basic selectors and error handling. Our requirements are:<\/p>\n\n\n\n

  1. For successful submission, all fields must be entered correctly within our validation rules<\/li>
  2. If one or more error occurs, the form will not submit. Feedback provided to the user<\/li>
  3. A correct form with no errors once submitted, will send an email to the recipient <\/li><\/ol>\n\n\n\n

    In real life we would most likely have a call to a web service or some other piece of code that would execute once a form was submitted with no errors.<\/p><\/blockquote>\n\n\n\n

    To get started, you will need to create a directory structure on your local computer that resembles the following:<\/p>\n\n\n\n