<html>
<body>
Search: <input type="search" id="mySearch">
<p>Click the button to set the maximum number of characters allowed in the search field.</p>
<p id="demo"></p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("mySearch").maxLength = "8";
document.getElementById("demo").innerHTML = "Maximum number of characters allowed in the search field is now 8.";
}
</script>
</body>
</html>