InterviewHubPRO
Section Overview
Q282

Question 282 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

54%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

Give an example usage of the rangeOverflow property

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
  <input id="age" type="number" max="100" />
  <button onclick="myOverflowFunction()">OK</button>
javascript
  function myOverflowFunction() {
    if (document.getElementById("age").validity.rangeOverflow) {
      alert("The mentioned age is not allowed");
    }
  }