Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
There is a checkValidity()
method in the latest version of javascript which works well with HTML5. By using the new
HTML5 form field attributes, you can check to see if the data submitted meets this criteria.
https://www.w3schools.com/js/js_validation_api.asp
Enter a number between 10 and 100.
function myFunction()
{
let input = document.getElementById("txtNumber");
if (input.checkValidity() === false)
{
document.getElementById("demo1").innerHTML = input.validationMessage;
}
}
You also chose to use some of the validity properties to test against.