asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Authoring Your Web Pages > Using Forms

Using Forms

Previous: Frames and Framesets


Form Controls

Form controls, also called form fields, are HTML elements that can accept information. Each type of form control operates a little differently, and what to use depends on how we want our site visitors to enter information.

The following example demonstrates the basic form controls we can include in our Web pages.

 Show me 

For a detailed discussion of elements that can be used in a FORM, please see INPUT, SELECT, and TEXTAREA controls.

Set data entry rules for applicable form fields

The third step in creating a form is to set rules for the way data is entered in certain fields in the form. These data entry rules, also called validation, ensure that a site visitor fills out the form correctly.

For example, we can set up a form that, unless the user fills out all entries, the user won’t be able to submit the form.

 Show me 

The following sections present some general pointers for form input validation. For a more thorough description of form validation functions, please consult the Data Entry Validation page.

Text box validation

We can specify what type of data to allow in the entry field and set other criteria for text boxes.

For example, to obtain a credit card number, we can set up a one-line text box to accept only numbers and hyphens, and disallow all other characters. We can also require a fixed number of characters, or field length, so that a user does not omit a number by mistake.

Radio button validation

We can require a selection to be made from a group of radio buttons. For example, a form may have two radio buttons, Yes and No. If a site visitor tries to submit the form without making a selection, a message is displayed.

Drop-down menu validation

We can also require a site visitor to make a choice from a drop-down menu, set the minimum and maximum number of choices to allow, and even disallow the first choice from being selected (for example, to disallow the first item from being selected, if it is an instruction, such as "Select an item").

Setting up How to Handle Form Results

The fourth step in creating a form is to set up how we want to save the data gathered from the form after a site visitor fills it out.

When a site visitor clicks the submit button on the form, the form results will be sent to the location we specified, where a script can be set up to work with the data as needed.

Following are some of the more common methods of handling from results, though details of form handler scripting is beyond the scope of this tutorial.

  • Save the results to a text or HTML file. Each time a site visitor submits a form, this method appends the results to a file. We can then open the file and view the results.
  • Send the results in e-mail. Each time a site visitor submits a form, a script can be used to send an e-mail message containing the results of that form.
  • Save the results to a database. Each time a site visitor submits a form, a script can save the information to a database. For example, we use a form to collect contact information, and the script saves the results directly to a customer database.

Note that most of these scripts require server-side extensions that must be installed on the server on which your Web site is located.

Some relevant external references:

 

Previous: Frames and Framesets


Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note