-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice.html
61 lines (52 loc) · 1.7 KB
/
practice.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!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>practice</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<h1>
Loading...
</h1>
<button class="loaded-button">loaded</button>
<button class="call-api">loaded</button>
<p class="api-response"></p>
<input type="text" class="passwordcheck"/>
<button class="checkpass">check button</button>
</body>
<script>
var inputOne=document.querySelector('.passwordcheck')
var checkBtn=document.querySelector('.checkpass')
checkBtn.addEventListener('click',function() {
// var input=inputOne.value;
if(inputOne.value.length<=8){
console.log('value should be greater value')
inputOne.style.border="1px solid red"
}else{
console.log('value is ok ')
inputOne.style.border="1px solid green"
inputOne.style.display="none"
}
})
var callApiBtn = document.querySelector('.call-api')
var apiRes = document.querySelector('.api-response')
// https://api.funtranslations.com/translate/irate.json?text=Hello%20sir%21%20my%20mother%20goes%20with%20me%20to%20the%20ocean.
function calltheApi() {
fetch(`https://api.funtranslations.com/translate/minion.json?text=${"My name is mohd imran"} `).then(response =>
response.json()
).then(json => {
console.log(json)
var trans=json.contents.translated;
apiRes.innerText=trans;
apiRes.style.textTransform="capitalize"
}
).catch(error => {
console.log(error)
})
}
callApiBtn.addEventListener("click", calltheApi);
</script>
</html>