-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (57 loc) · 1.98 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>What is Javascript?</title>
<!-- Mastering Javascript -->
<!-- powered by skillnagar.com -->
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<style>
body {
background: #efefef;
font-family: 'Roboto', sans-serif;
}
h1 {
text-align: center;
margin-top: 200px;
}
input {
width: 300px;
display: block;
margin: 5px auto;
height: 25px;
border: 1px solid #48adff;
border-radius: 5px;
outline: none;
padding: 5px;
font-size: 18px;
}
p {
text-align: center;
}
</style>
</head>
<body>
<h1>What is Javascript?</h1>
<input type="text" id="myInputText" />
<p id="myFeedback"></p>
<script>
var myInputText = document.getElementById("myInputText");
myInputText.addEventListener("keyup", function() {
if(myInputText.value.length > 0) {
if(isNaN(myInputText.value)) {
// you are entering a non numeric value
document.getElementById("myFeedback").innerHTML = "You are entering a <strong>non numeric</strong> value and length of your string is <strong>" + myInputText.value.length + "</strong>";
} else {
// you are entering a numeric value
document.getElementById("myFeedback").innerHTML = "You are entering a <strong>numeric</strong> value and length of your string is <strong>" + myInputText.value.length + "</strong>";
}
} else {
document.getElementById("myFeedback").innerHTML = "";
}
});
</script>
</body>
</html>