Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions JavaScript/Advance/Web API/web-form API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web-Form API</title>
</head>

<body>
<h1>Web Form Validation API</h1>
<!-- Example Three -->
<h2>checkValidity</h2>
<input id="inputOne" type="number" min="100" max="300" required>
<button onclick="DisplayOne()">Click</button>
<p id="textOne"></p>
<!-- Example Two -->
<h2>rangeOverflow()</h2>
<input id="inputTwo" type="number" max="100">
<button onclick="DisplayTwo()">Click</button>
<p id="textTwo"></p>
<!-- Example Three -->
<h2>rangeUnderflow()</h2>
<input type="number" min="100" id="inpThree">
<button onclick="DisplayThree()">Click</button>
<p id="textThree"></p>
<script src="script.js"></script>
</body>

</html>
38 changes: 38 additions & 0 deletions JavaScript/Advance/Web API/web-form API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Validation in JavaScript API
There many types of Validation at first we will try
1.checkValidity()
*/

let textOne = document.getElementById('textOne');

function DisplayOne() {
const InpObjOne = document.getElementById('inputOne');
if (!InpObjOne.checkValidity()) {
textOne.innerHTML = InpObjOne.validationMessage;
} else {
textOne.innerHTML = "Great it's OK!"
}
}

// 2. rangeOverflow Property

let textTwo = document.getElementById('textTwo');

function DisplayTwo() {
let inputTwo = document.getElementById('inputTwo');
if (inputTwo.validity.rangeOverflow) {
text = "Value is Too Large"
}
}


// 3. rangeUnderflow Property

let textThree = document.getElementById('textThree');

function DisplayThree() {
let inpThree = document.getElementById('inpThree');
if (inpThree.validity.rangeUnderflow) {
textThree.innerHTML = "Value is Too Small"
}
}