Working with Password Fields


Password fields are like text fields, only the text inside them appears dotted out, as in Figure 68.8. You typically use these kinds of fields to accept passwords, naturally, or any other kind of input that you would rather not display literally on screen.

Figure 68.8. Use password fields when you don't want to display the exact text of the field on screen.


FAQ

Can you use password fields for other kinds of input?

Certainly. You don't have to restrict password fields to passwords only. PINs, keycodes, and account numbers are all viable candidates for this type of widget.


Listing 68.8. View Source for Figure 68.8.
 <form>   <strong>Password:</strong>   <input type="password" name="userPassword" value="ladda"> </form> 

In this example, the password field has a preset value. That is, the text of the value attribute appears in the password field when the page loads. If you don't want your password field to load a preset value, simply leave this attribute out:

 <input type="password" name="userPassword"> 

TIP

As with text fields and file fields, you set the physical width of a password field with the size attribute, and the maximum number of characters that the visitor can enter with the maxlength attribute.


Even though the browser conceals the actual value of the password field on screen, the Web server receives the literal text inside the password field upon submission, along these lines:

 userPassword=ladda; 



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net