<!DOCTYPE html>
<html>
<head><title>Form Validation API</title>
<style>p#demo {color:Red;}</style>
</head>
<body>
<p>Enter a number and click OK:
<input id="id1" type="number" min="100" max="300" step="10" required>
<button onclick="myFunction()">OK</button>
</p>
<p id="demo"></p>
<!-- the validationMessage property contains the default error message. -->
<script>
function myFunction() {
const inpObj = document.getElementById("id1");
if (!inpObj.checkValidity()) {
document.getElementById("demo").innerHTML = inpObj.validationMessage;
} else {
document.getElementById("demo").innerHTML = "Input OK";
}
}
</script>
</body>
</html>