-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (29 loc) · 927 Bytes
/
script.js
File metadata and controls
39 lines (29 loc) · 927 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
39
(function () {
var ex1_button = document.getElementById("ex1_button");
var ex1_content = document.getElementById("ex1_content");
})();
ex1_button.onclick = function () {
var tabela = [];
for (var i = 0; i <= 9; i++) {
tabela.push(i);
}
ex1_content.innerHTML = tabela.toString();
};
var ex2_text = document.getElementById("ex2_text");
var ex2_content = document.getElementById("ex2_content");
ex2_text.addEventListener("input", function() {
var phoneNumber = ex2_text.value;
if (phoneNumber.length !== 9) {
ex2_content.innerHTML = "Długość numeru musi być równa 9";
return;
}
if (/[a-zA-Z]/.test(phoneNumber)) {
ex2_content.innerHTML = "Numer nie może zawierać liter";
return;
}
if (/[^0-9]/.test(phoneNumber)) {
ex2_content.innerHTML = "Numer nie może zawierać znaków specjalnych";
return;
}
ex2_content.innerHTML = "Numer telefonu jest poprawny";
});