Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,900 courses, including more Developer and personalized recommendations.Start Your Free Trial Now
- View Offline
- Understanding forms
- Adding required fields and placeholders
- Accepting multiple entries
- Limiting uploads
- Handling focus changes
- Validating with regular expressions
- Working with older browsers
- Building jQuery validation
- Using server-side validation
- Sanitizing form input
- Uploading files
- Sending form data to a database
Skill Level Intermediate
Even though it might be obvious to some, I wanted to take a minute to review how forms are used on the web, how they're created, and what the different options for validating and processing them are. So let's get started by talking about what forms are for. Forms are designed to handle communication between the client, which is usually a browser, and a server, which hosts web sites and processes requests for information. It's a great way for your server to gather data about your user and do something in response to user input. Forms can let your user interact with data so that you can provide an interactive or customized experience.
So, let's talk about how they work. You can interact with a form through a series of Input and Control Fields, like Text Fields, Check Boxes, Radio buttons and Drop Downs. The browser gathers the data from these fields and sends them to a processing script in a language like PHP or Ruby. The form processor receives the data from the form and does something with it, sometimes returning the data immediately to the browser through AJAX or by calling a separate page. So how does that processing work? Processing means taking the data that a user enters and sending it to the server.
Input fields send over name and value pairs with the name of the field and one or more values. This data has to be parsed, or translated, by the server-side language, processed, and then usually sent to a database, or used to create a custom experience for the user. The result of processing can then be sent back to the user through AJAX, or by sending the user to a new page with the results from the form. Validation is the process of verifying that the information the user submits is in the right format. You perform validation on forms to make sure that no harmful data is passed to your site or database.