-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (29 loc) · 940 Bytes
/
Copy pathscript.js
File metadata and controls
38 lines (29 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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"
}
}