Following pictorial shows in which field, what validation we want to impose.We will create Java Script functions (one for each input field whose value is to validate) which check whether a value submitted by user passes the validation.Contact form of websites led user to communicate with website owners.This shows a genuine or loyal behavior of an organization towards its customers.Sure, it may not look nice and tell you someone has been trying to mess with your script, but the important thing is he/she had failed! If you know exactly what kind of data to expect you can make further steps to ensure the user has entered what you want. Instead of writing the same code over and over again we can create a function that will do all the checking for us.We will cover a few samples like validating e-mail address and URLs later. Here we will name it check_input and simply call this function whenever we need to validate simple input data: Note the check_input function at the bottom.In this tutorial, we will see how to use PHP to validate the data collected from a form.You will see how to validate various fields used in general, like text, list, checkbox, radio button and we will also see how to retain POST data, so that after the user submits the form, even if the data supplied is not valid, data is not lost.
Additional plug-in subclasses are provided to retrive option groups from a My SQL database or many other SQL databases using the Metabase PEAR:: MDB2 PHP database abstraction layer APIs * Manage animations that apply visual effects to the page form elements, like: fade-in, fade-out, show, hide, update content, etc.. - Load submitted form field values even with register_globals option Off and strip slashes when magic_quotes_gpc option is On. * Field equal to another (useful for password confirmation fields).is the external Java Script file which contains the Java Script ocde used to validate the form. Notice that for validation, the Java Script function containing the code to validate is called on the on Submit event of the form. Flowchart : Here is the entire Java Script used for validation of the form.For the sake of demonstration, we have taken five countries only. function form Validation() function userid_validation(uid,mx,my) function passid_validation(passid,mx,my) function all Letter(uname) function alphanumeric(uadd) function countryselect(ucountry) function allnumeric(uzip) function Validate Email(uemail) function validsex(umsex,ufsex) Flowchart : Download the Validation code from here.All those functions are called from another function.It sets the focus to the input field until the user supplies a valid value.
Live Demo Following is a live demo of the PHP form we will create by the end of this tutorial.