When we display the form back again, it should not loose the form data the user already had filled-in.So we have to display the value from the $_POST in the input value attribute.You can see that the page consists of a Java Script function called That's all there is to simple Java Script form validation!Our example is very simple as it only checks one field.Client-side form validations help in giving immediate feedback to the user.It is also required to add server side form validation in your form processing script.Drop down lists or radio groups can be used for single selections and lists with multiple selections are not user friendly. As you have seen in the previous section, the values for the checkbox group come as an array. Shows you how to write a script that ensures your form is filled in correctly before it's sent to your server.
When you have fields like name or email as mandatory in the form, it should be checked in the server side script as well. Here is the sample output from that script: Note that the “Filling” checkbox group in the HTML form results in an array in the PHP script The rest of the fields appear as simple name-value pairs To validate mandatory fields, we just have to check the presence of the value in the $_POST array.