Password Fields

The password field is almost identical in the way that it works to the text field.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<h1>Password Fields</h1>
<form action="#">
<label for="pass">Password:</label>
<input type="password" size="10" id="pass" name="pass" />

Here's what the Password Form page looks like in your web browser.

Again we use a label tag to define the label that is to be associated with our password field. Again we use an input tag to define the actual field.

What we have done is to change the type from text to password and have dropped the value attribute. Specifying a field type of password means that the field will not display the actual characters that are typed in but will instead substitute asterisks. By defining a field this way you avoid the problem of a passer-by seeing the password on the screen as it is being entered. At best from looking at the screen they can see how many characters a password contains but not what those characters are.

Note that the actual value entered is available as clear text for processing in any Javascript attached to the form and is also passed in clear text when the form is submitted. The only difference that specifying a password field makes is that the field itself doesn't display the value entered in clear text.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow