Form Submission | Web page
the submission of the form
now that the form is used to capture data entered by the user, then, you should ensure that the user's data are accurately submitted to the intended location, that is, we submit in the form of the user's data should be tested, one can avoid users to lose data, and then to avoid user input illegal, or unqualified data, after the inspection, but also to ensure that the user's data submitted to a specific program.
data inspection, there are usually two kinds of procedures: client-side inspection and server test. Client testing, relatively fast, server-side testing, relatively slow, in order to ensure security, usually at the same time, so that users can avoid deliberate destruction.
no matter what way, the principle of data testing is the same, once the user input data does not meet the requirements, the error, requiring users to re-enter, client-side inspection often use Javascrip script, server-end depending on the system, this article does not examine the specific procedures for the design of data, Just cite a few examples to illustrate.
Examples: Required fields, and simple data type validation
The following must be entered with *:
Name: *
Email: *
Functional Implementation Analysis:
This example adds a onsubmit event to the form, which must be checked by the function checkdate (), if unqualified, to return the input data before submitting it;
The functions of the data validation are as follows: <script> function checkdate () {//Get input data UserName = document. RedForm.userName.value; UserEmail = document. RedForm.userEmail.value; If you do not enter a name if (username== "") {alert ("Please enter a name"), document. RedForm.userName.focus (); return false; }else{//If no email is entered, or email address error (without @) if ((useremail== "") | | (Useremail.indexof ("@") ==-1) {Alert ("Please re-enter email address") document. RedForm.userEmail.focus (); return false; }else return true; }} </script>
A branch submission for a form
Sometimes, a form needs to be submitted to a different program according to the user's choice, how to do it? The user's selection branch is detected through the script, submitting the form to different programs to see the sample:
Sample: Branch submission
User name: Password:
Company users Individual users
Functional Implementation Analysis:
The
first use here is the form and then according to the selected branch, to submit to the different program, Twosubmit () function as follows: <script> function Twosubmit (form) {if (form). ref[0].checked) {form.action = "cop.asp";//Here is one of the points}else{form.action = "ind.asp";//Here is the minute of the second} form.submit (); } </script>
submit a form with any element
is it just a button or Picture button to submit the form? Of course not, in fact, any page element can submit the form, but it is done through the script, below we use the link to replace the submit button:
Example: Submitting a form with a link
User name: Password:
Log in
emptied
Functional Implementation Analysis: By submitting the form, and resetting the form, any element can implement the submit form.
in Dreamweaver, it is easy to set up a Drop-down menu based on a form, which is described here to cater to the Dreamweaver user.
Sample: Drop-down Jump menu based on form
Web page Production GuideFree Build Station ResourcesWeb production software
Functional Implementation Analysis: In fact, a function is used to jump to the selected address, <script language= "JavaScript" > Function Formmenu (targ,selobj,restore) { Eval (targ+ "location=" "+selobj.options[selobj.selectedindex].value+"); if (restore) selobj.selectedindex=0; }</script> then, give the Drop-down selection box an event, it's OK.
submit a form by email (for Outlook users only, not for foxmail users)
Functional implementation Analysis: Look at our form tags are known, the format is as follows: Here's the mailto: Add the address to receive the message,? Subject is to set the default email title, enctype= "Text/plain" is necessary to indicate that the information is submitted in text, without any encryption, so this method is often used in the absence of asp/php/cgi support space, but also a proxy method, The user must have Outlook installed and is the default mail program to perform the commit successfully.