<!DOCTYPE html>
<html>
<body>
<h2>JavaScriptの検証</h2>
<p>数値を入力して「OK」をクリックします。</p>
<input id="id1" type="number" max="100">
<button onclick="myFunction()">OK</button>
<p>数値が100(入力のmax属性)より大きい場合、エラーメッセージが表示されます。</p>
<p id="demo"></p>
<script>
function myFunction() {
let text;
if (document.getElementById("id1").validity.rangeOverflow) {
text = "Value too large";
} else {
text = "Input OK";
}
document.getElementById("demo").innerHTML = text;
}
</script>