Input Search maxLength Property - Change the maximum number of characters allowed in a search field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Search

Description

Input Search maxLength Property - Change the maximum number of characters allowed in a search field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Search: <input type="search" id="mySearch">

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

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/* w ww  . j a v  a2  s  .  co  m*/
    document.getElementById("mySearch").maxLength = "8";
    document.getElementById("demo").innerHTML = "Maximum number of characters allowed in the search field is now 8.";
}
</script>

</body>
</html>

Related Tutorials