Advertisement
728x90
If an element's value is greater than its max attribute then the rangeOverflow property is true. For example, the below form submission throws an error if the value is more than 100,
html
1<input id="age" type="number" max="100" />
2 <button onclick="myOverflowFunction()">OK</button>javascript
1function myOverflowFunction() {
2 if (document.getElementById("age").validity.rangeOverflow) {
3 alert("The mentioned age is not allowed");
4 }
5 }Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 21
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
278of476