<!DOCTYPE html>
<html>
<body>

Search: <input type="search" id="mySearch" maxlength="30">

<p>Click the button to display the value of the maxlength attribute of the search field.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySearch").maxLength;
    document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>