Validating a form with php
We create and associate a set of “validation descriptors” with each element in the form.The “validation descriptor” is a string specifying the type of validation to be performed.When the user does so, they may proceed and can supply value to the next available field.The later Java Script function created is called on the onsubmit event of the form. If Male or Female is selected, it generates an alert saying that the form is successfully submitted and it reloads the form.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.
It sets the focus to the input field until the user supplies a valid value.
You may opt for sending form data to a different file.
Validation for non-empty, alphabets and whitespace only The following code is added within the form So, if you try to understand how to write code for it step by step, step 1 is to declare the mail address to whom you want to send mail, step 2 is to write subject of the mail, step three is to collect data from POST so that you can write them to the body of mail, step 4 is to declare the mail id from which the mail is coming and finally sent mail with PHP mail() function.
PHP is a great scripting language that allows many dynamic functions in your site.
You can create custom forms, form validation, and email responses using PHP.