<p>
<label for="password">Your password</label>
<input id="password" type="password" minlength="8" maxlength="20" />
</p>HTMLInputElement: maxLength property / notebook
HTMLInputElement: maxLength property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const inputElement = document.querySelector("#password");
console.log(`Element's maxLength: ${inputElement.maxLength}`); // "Element's maxlength: 20"
inputElement.maxLength = 18; // updates the element's maxlength attribute value