Validating a form in php

26 Feb

Before we get started, go download the following javascript files: After you have downloaded those three files, place them in a folder named js in the directory where you want to have your contact form.Now you’re ready to start crafting the contact form!This tells the form what to do when the form is submitted successfully.In there we tell the entire form to hide itself by sliding up, and we then insert the response text into the #response div.More specifically, by adding javascript to this contact form, we will be adding validation (making sure the user enters acceptable things into the different fields) and ajax in a nice blend of usefulness. Anything inside the function’s curly brackets will run as soon as the page has finished loading.This is telling the Validate plugin that we downloaded and included earlier to validate the #contactform form.

It’s a lifesaver and you should learn to use it if you ever want to get anywhere with your web design.Here’s what the different arguments do: The rules option specifies the details of each input element in the contact form.As you can see, every one of the inputs is required, and the name and message text boxes have minimum amounts of characters allowed.First off, make sure that you have a basic understanding of HTML, PHP, and Javascript.W3is a great resource for quickly getting up to speed with these languages.