INPUT Form Type: TEXT Illustrated with Attributes.

The form TYPE  attribute sets the type of field for INPUTs. There are a number of types you may wish to use, including: text, password, checkbox, radio, submit button, reset button, buttons and images.    On this page I  will demonstrate the INPUT TEXT field, which is the default field if you do not specify the type attribute.   Other INPUT fields will be demonstated on another page.

I  illustrate various attributes which can be used with input files and show  how to place labels for the form fields.

In all of these examples, I have the code used to produce a form, followed by the resulting form.  In each case, the form data is sent to be processed by a  CGI script at: http://webdevfoundations.net/scripts/formdemo.asp   This script returned the data entered for the form transmitted, associated  with the form name field.    Unfortunately this script may not be operational.  Sorry, if this is the case, but  you can still fill out the form fields and submit data.

blueline.gif (1205 bytes)

  • TEXT--text fields are simple text entry fields. Text is the default field if you do not specify the type attribute.  The default length of a text box is 20 characters.

    <FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">

      <INPUT TYPE="text"  NAME="text">
      <INPUT TYPE = "submit" value="try me">
     
    </form>

blueline.gif (1205 bytes)

Attributes That May be Specified Include:

  • Type - Along with the INPUT type, SELECT and TEXTAREA will be covered later.   
  • The NAME  attribute allows you to identify a specific form entry. You should always include this attribute.  The user doesn't see this name, but it is returned to you along with data entered in that field,  when the ACTION is executed.
  • You can set the SIZE  and the MAXLENGTH  of the field.
  • The VALUE  attribute lets you select a default value for the field.
  • A special attribute CHECKED  sets the default values of a radio button or checkbox covered later.

blueline.gif (1205 bytes)

NAME Attribute:
Although the following fields appear identical, they  have different names, and the names associated with the data in each field will be different.

<FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">

  <INPUT TYPE="text"   NAME="first"   VALUE="initial text">
  <INPUT TYPE="text"  NAME="second"    VALUE="initial text">
  <INPUT TYPE = "submit" VALUE="try me">
 
</form>


blueline.gif (1205 bytes)

VALUE Attribute:
These two fields have different values, the value attribute is used to give initial values to fields, or to specify labels for buttons submit and reset.

<FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">
 
  <INPUT TYPE="text"  NAME="text 1"   VALUE="First" >
  <INPUT TYPE="text"   NAME="text 2"  VALUE="Second" >
  <INPUT TYPE = "submit" VALUE="try me">
 
</form>


blueline.gif (1205 bytes)

SIZE & MAXLEN Attributes:

These fields have different sizes.  Use size to override the default size of 20 characters.

<FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">
 
  <INPUT TYPE="text" NAME="text 1"  SIZE=2 >
  <INPUT TYPE="text" NAME="text 2" SIZE=40 >
  <INPUT TYPE = "submit" VALUE="try me">
 
</form>

This field has the maxlength set to ten. Although the field size is actually 30  characters long, you can not type past the tenth character. Try it.

<FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">
 
  <INPUT TYPE="text" NAME="text"   SIZE=30   MAXLENGTH=10 >
  <INPUT TYPE = "submit" value="try me">
 
</form>

blueline.gif (1205 bytes)

Form Labels For Text Boxes:

You may be wondering how to indicate to the user what should be typed into these form fields.  Just enter text between the <input ... tags  as follows:

<FORM ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">

  Enter First Name: <INPUT TYPE="text"   NAME="first"> &nbsp;  &nbsp;  &nbsp;  &nbsp;

  Last Name:   <INPUT TYPE="text"  NAME="second">

  <p> <INPUT TYPE = "submit" VALUE="Send Name">
 
</form>


Enter First Name:         Last Name:    

blueline.gif (1205 bytes)

 

        

Last updated on 02/09/2009   by L.M. Hicks