-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday5.js
107 lines (80 loc) · 2.3 KB
/
day5.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// var x = 0;
// switch (x) {
// case 0:
// console.log("hello");
// break;
// case 1:
// console.log("world");
// break;
// default:
// console.log("invalid");
// }
// on click
// var btn = document.getElementById("our-btn");
// btn.onclick = function (e) {
// console.log("hello");
// };
// on focus
// var inp = document.getElementById("inp-box");
// var tips = document.getElementById("pswd-tips");
// tips.style.display = "block";
// inp.onfocus = (e) => {
// tips.style.display = "block";
// };
// // on blur
// inp.onblur = (e) => {
// var pswd = e.target.value;
// if (pswd.length >= 8) {
// alert("Your password is accepted!");
// } else {
// alert("Please enter a password with minimum 8 character");
// }
// tips.style.display = "none";
// };
// on change
// console.log(inp);
// inp.addEventListener("change", function (e) {
// console.log("your current input is", e.target.value);
// });
// inp.addEventListener("event name", <Function>)
// var paragraphs = document.getElementsByClassName("paragraph");
// console.log(paragraphs);
// for (var i = 0; i < paragraphs.length; i++) {
// paragraphs[i].style.color = "blue";
// }
// var tags = document.getElementsByTagName("p");
// for (var i = 0; i < tags.length; i++) {
// tags[i].style.color = "green";
// }
// function funcname() {
// }
// const funcname = function(){
// }
// const funcname = () => {}
// var p = document.getElementById("id");
// p.innerHTML =
// "<h1>Hello World</h1><h2>Skfgi</h2><p>hello</p><img src='https://picsum.photos/128' />";
var form = document.getElementById("our-form");
var err = document.getElementById("error-msg");
err.style.display = "none";
var roll = document.getElementById("roll");
var age = document.getElementById("age");
age.oninput = (e) => {
if (e.target.value > 200 || e.target.value < 0)
alert("Please enter a valid age");
};
roll.oninput = (e) => {
if (String(e.target.value).startsWith("253001190")) {
err.style.display = "none";
} else {
err.style.display = "block";
}
};
form.onsubmit = (e) => {
e.preventDefault();
var name = document.getElementById("name");
var roll = document.getElementById("roll");
console.log("You submit with name", name.value, "and roll", roll.value);
};
var x = prompt("Enter a number");
console.log(x);