Add required fields and placeholders JavaScript and PHP Forms JavaScript Forms


show more Adding required fields and placeholders provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the Validating and Processing Forms with JavaScript and PHP show less
please wait ...

Adding required fields and placeholders

One of the most helpful HTML5 atrributes for form validation is the required attribute. On browsers that support it, it will prevent the form from being submitted unless the input is filled out. I'll be using this form from our exercise files. This is one of the forms I styled in my course on CSS styling forms. If we take a look at the code for this page, you can see a single input field. I'm going to add the required attribute to the input field and then switch over to the browser. I'll refresh the form. And if I try to submit it without filling it out, I'll get a little error message that says please fill out this field. It also won't let me submit the form.

When you use the required attribute, it's always a good idea to also use the placeholders attribute. Placeholders give users a hint as to how they're supposed to fill out our field. That way, the user will know that I don't simply want their first name. Let me refresh this page. And you...

Adding required fields and placeholders
Video duration: 1m 31s 2h 51m Intermediate

Viewers:

Adding required fields and placeholders provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the Validating and Processing Forms with JavaScript and PHP

Subjects:
Developer Web
Software:
JavaScript PHP
Author:
please wait ...