Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
JavaScript by Example

You're reading from   JavaScript by Example Learn modern web development with real-world applications

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781788293969
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dani Akash S Dani Akash S
Author Profile Icon Dani Akash S
Dani Akash S
Arrow right icon
View More author details
Toc

Validating and submitting the form using JavaScript

HTML Forms are the most important part of web applications, where user input is recorded. In our JS Meetup app, we got a nice looking form built with the help of Bootstrap. Let's explore what the form contains using the index.html file. The form contains four compulsory fields:

  • Name
  • Email Address
  • Phone Number
  • Age

And it also contains three optional fields (two of whose values are preselected):

  • The user's profession
  • His experience level in JavaScript
  • Comments on what he expects to learn from this event

Since profession and experience level options are preselected with a default value, they aren't marked as compulsory to the user. But, during validation, we need to consider them as compulsory fields. Only the comments field is optional.

Here's how our form should work:

  • The user fills up all the form details...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime