Latest web development tutorials

HTML DOM Password maxLength property

Password Object Reference Password objects

Definition and Usage

maxLength property sets or returns the maximum number of characters allowed in the password field.

grammar

Setting maxLength properties:

passwordObject.maxLength=integer

Back maxLength attributes:

passwordObject.maxLength


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support maxLength property


Examples

Examples

The following example shows the maximum number of characters allowed in the password specified domain:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
var x = document.getElementById ( "pwd") maxLength.;
alert (x);
}
</ Script>
</ Head>
<Body>

<Form>
Password: <input type = "password" id = "pwd" maxlength = "8">
</ Form>
<Button type = "button" onclick = "displayResult ()"> to display allows the maximum number of characters entered. </ Button>

</ Body>
</ Html>

try it"


Password Object Reference Password objects