HTML Forms: input

<input> tags are placed within a form, and need to have a name in order for their values to be passed in the query string.

type=text

Creates a box for the input of one line of user-typed text.
This is the default, so you may specify type="text" but you don't have to.
Other, optional attributes are:

value

The initial value appearing in the box. By default, there are no characters in the value.

size

An integer that controls the width of the box, it represents the (approximate) number of characters that can fit in it, but does not restrict the length.

maxlength

An integer limiting the number of characters that can be entered. This would be good to use if you plan to store the value in a database, where generally you limit the length of character strings.

Examples:

Enter your user name and password:


Enter your user name and password:<br>
<input name="user" type="text" value="Your name here" size=30 maxlength="40"><br>
<input name="pass" type="password" size="15" maxlength=12>
<br> <input type="submit" value="Test this"> <input type="reset">

type=password

This is the same as type=input except that the characters typed do not show in the box, instead you will see **'s spots, or similar. Note also that many browsers will erase passwords when a form is submitted, and may also ask you if you want to save the password.
Even though the "password" does not show in the box, it will show up in the query string, and be transmitted as is over the internet. For maximum confidentiality, use POST rather than GET, and also use encryption (https).

Back to forms, or on to radio and checkbox
Up to csc103 intro