From the course: JavaScript: Web Form Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Leveraging basic browser validation

Leveraging basic browser validation

From the course: JavaScript: Web Form Programming

Start my 1-month free trial

Leveraging basic browser validation

- One of the easiest ways to help reduce form data errors, is to constrain the information that the user can enter into any given field. So let's open up the basic validation start file. And let's go ahead and bring this up in the browser as well. And you can see that this is a similar version of the stock purchasing form that we used for the output element example. So, the first problem that we want to fix is that we want to make sure that the user enters a stock symbol. So that they can't leave this field blank. So let's go back over to the code. And what we're going to do is to ensure that a value is entered. We're going to use the required attribute. So I'm going to scroll down here to my stock symbol input field and I'll just simply add the required attribute. So now, the user can't submit the form without a value being in that field. And we can do the same thing for the email field. So let's go ahead and scroll…

Contents