asp.net.ph

Skip Navigation Links

INPUT type=password Element

HTML Elements


Creates a single-line text entry control that conceals the actual value of the entry.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

Remarks

The INPUT type=password element is similar to the single-line textbox, but the input text is rendered in such a way as to hide the characters ( e.g., a series of asterisks ) as the user enters it. This control type is often used for sensitive input such as passwords .

Application designers should note that although the control does not display the actual text, this mechanism affords only light security protection. Even if the password is masked by user agents from casual observers, it is transmitted to the server in clear text, and may be read by anyone with low-level access to the network.

Members

INPUT Members

Example

The following example defines a password field.

<form name="theForm">
   Username: <input id="txtUser" size=15><br>
   Password: <input type="password" id="txtPass" size=15><br>
   <input type="button" value="Enter" onclick="getPass ( )">
</form>

The following script checks to see if the password is valid for the specified user.

<script language="JavaScript">
<!--
function getPass ( ) {
if ( document.theForm.txtUser.value == "John" )
   if ( document.theForm.txtPass.value == "Doe" )
      alert ( "Password accepted. Enjoy your ride." );
   else
      alert ( "Password not valid. Sorry." );
else
   alert ( "Login not valid. Sorry." );
}
//-->
</script>

The preceding HTML and script are implemented below. Type in John as user and Doe as password or try something else.

Username:
Password:

See Also

INPUT



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note