<html>
<body>
<form action="/action_page.php" method="get">
Name: <input type="text" id="myInput" name="fname" pattern=".{6,}" required>
<input type="submit" value="Submit">
</form>
<p>If you submit the form with less than 6 characters, an alert message will occur.</p>
<script>
document.getElementById("myInput").addEventListener("invalid", myFunction);
function myFunction() {
alert("Must contain 6 or more characters");
}
</script>
</body>
</html>