JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Creating Password Controls

You can convert a text box into a password control, where the text the user types is masked with asterisks (*). You can see this in the Textboxes example on the CD-ROM in Figure 15.8. You create a password control by setting a text box's TextMode property to Password, as I've done for the text box under the button in the Textboxes example. In HTML, this becomes an <input> element with the type attribute set to "password":

<input name="TextBox3" type="password" id="TextBox3"
style="height:24px;width:118px;Z-INDEX: 104; LEFT: 101px;
POSITION: absolute; TOP: 146px" />

In code, you can read the text in the password control using the control's Text property, as I do in the Textboxes example, where I transfer the text from the password control to the text box under it, like this:

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = "You clicked the button."
        TextBox2.Text = "You clicked the button."
        TextBox4.Text = TextBox3.Text
    End Sub

You can see the result in Figure 15.8.


Although the security of password controls isn't to be relied on too heavily, it's worth noting that the browser is smart enough to thwart someone who just tries to copy the masked password and paste it into another application to read it; you can't actually copy password text, because nothing is placed into the clipboard when you try.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor