menu_book Course Curriculum (HTML) expand_more
Constraint validation API
Learn Constraint validation API in HTML through one focused, topic-specific example.
Constraint validation API is a concrete HTML behavior inside Forms and Controls. This lesson focuses on the actual markup contract: what the browser parses, what users and assistive technology receive, and which attributes change that behavior.
Read the example as document structure rather than decoration. Identify the element or attribute that carries the meaning, then check the edge case called out below. Valid-looking markup is not automatically semantic markup.
Topic-specific example
<form id="signup"><input id="handle" required minlength="3"><button>Join</button></form>
<script>const h=document.querySelector("#handle"); h.setCustomValidity(h.value === "admin" ? "That handle is reserved." : "");</script>
Use Constraint validation API for its semantic purpose rather than because its default browser styling happens to look convenient.