SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Form data validation

As you have seen we have studied how the post back values inside a form of a text box, radio button, checkbox and drop down selection box is handled. Now we will try to combine this entire components and keep them inside one form. Then we will develop a script which will handle the data once the form is submitted and do a check ( or validation ) for all the components. If the validation is passed then it sends the visitor to a thank you page saying thanks to the visitor for the data, if the validation fails then it will post back the data to the form page with error messages. Here the post back data will be used to fill the components which the user previously filled with data so the visitor will only modify the error part. We will call it data locking

Related Tutorial
Ajax Form Validation
Now in this post back operation we will be assuming that register global is OFF so we will be taking special care to collect data at different pages.

We will also be using header redirection for sending back the visitor to thank you page ( after successful validation ) or back to from with error message once the validation fails.

There are three pages in the script. The form.php page displays the form. This page also receives all the post back data and create the default values of the components. We need not discuss here again how that is done, you can read all the individual form component validations here, with link to different section.

form-check.php checks the form input and does the validation. If the validation passes then it redirect to form-thank.php otherwise it sends back to form.php page with the post back data.

form-thanks.php only display the thank you message.

Here is a demo.
Name
SexMale |Female |
Languages you knowPHP ASP   JavaScript
Select one day
Try Again









Download the full script of form validation




Further readings
All form components validation with post back and data locking
Checkbox
How to retain form data if validation fails?
How to retain data of a text box after submitting
Retaining status of a check box
Updating checkbox value from & to a table record.
Retaining selected data of a period button of a form
Retaining selected data of a drop down list box of a form
Handling drop down list box with multiple selection options using array
Validating Date: Checking if date exist
Email address validation in a form
Email validation using Ajax & PHP
PHP Form Validation
is_numeric to check numeric numbers
is_int to check integer
ctype_alnum to check alphanumeric characters data
ctype_alpha to check alphabetic characters data
How to take care of form & query string variables if Register global is OFF?















Join Our Email List
Email:  
For Email Newsletters you can trust
Form handling
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2013 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer