-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeature.js
More file actions
158 lines (122 loc) · 4.03 KB
/
feature.js
File metadata and controls
158 lines (122 loc) · 4.03 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
function getCurrentDate(){
let date = new Date();
const day_name = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
let day_number = date.getDate();
let day = day_name[date.getDay()];
const month_name = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
let month = month_name[date.getMonth()];
let year = date.getFullYear();
return day + ", " + month + " "+ day_number + " " + year;
}
function getCurrentTime(){
let time = new Date();
document.getElementById("time").innerHTML = time.toLocaleTimeString();
}
function isEmpty(){
if(document.getElementById("").value.length == 0) {
alert("empty")
}
}
function isEmpty() {
// Check for input text
var x = document.forms["myform"]["dog-or-cat"].value;
if (x == "") {
alert("Please specify the type of animal (Cat or Dog)");
}
// Check for radio buttons
var radioButton1 = document.getElementsByName("breed");
var indicator = 0;
for (var i = 0; i < radioButton1.length; i++) {
if (radioButton1[i].checked) {
indicator++;
break;
}
}
if(indicator==0)
alert("Please select the type of breed of your animal.");
var radioButton2 = document.getElementsByName("gender");
var indicator2 = 0;
for (var i = 0; i < radioButton2.length; i++) {
if (radioButton2[i].checked) {
indicator2++
break;
}
}
if(indicator2==0)
alert("Please select the gender of your animal.");
// Check for dropdown
var option = document.getElementById("age");
if(option.selectedIndex != 0){
}
else
alert("Select at least one of the options.");
// Check for checkboxes
var checkboxes = document.getElementsByName("environment");
var indicator3 = 0;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
indicator3++;
break;
}
}
if(indicator3==0)
alert("You need to check at least one boxe!");
}
function isEmpty2() {
// Check for input text
var x = document.forms["mysecondform"]["fname"].value;
if (x == "") {
alert("Please enter your first name");
}
var y = document.forms["mysecondform"]["lname"].value;
if (y == "") {
alert("Please enter your last name");
}
let pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
let email = document.getElementById("email").value;
if(!pattern.test(email)) {
alert("Enter a valid email")
}
var z = document.forms["mysecondform"]["dog-or-cat"].value;
if (z== "") {
alert("Please specify the type of animal (Cat or Dog)");
}
// Check for radio buttons
var radioButton1 = document.getElementsByName("breed");
var radioButton2 = document.getElementsByName("gender");
var indicator = 0;
for (var i = 0; i < radioButton1.length; i++) {
if (radioButton1[i].checked) {
indicator++;
break;
}
}
if (indicator == 0)
alert("Please select the type of breed of your animal.");
var indicator2 = 0;
for (var i = 0; i < radioButton2.length; i++) {
if (radioButton2[i].checked) {
indicator++;
break;
}
}
if(indicator2 == 0)
alert("Please select the gender of your animal.");
// Check for checkboxes
var checkboxes = document.getElementsByName("environment");
var indicator3 = 0;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
indicator3++;
break;
}
}
if(indicator3 == 0)
alert("You need to check at least one boxe!");
// Check for textarea
var i = document.forms["mysecondform"]["textarea"].value;
if (i == "") {
alert("Please fill in a description.");
}
}