-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (42 loc) · 1.84 KB
/
script.js
File metadata and controls
70 lines (42 loc) · 1.84 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
function giveAkanName(){
event.preventDefault();
var dayOfTheWeek = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var akanMale = ["Kwasi","Kwado","Kwabena","Kwaku","Yaw","Kofi","Kwame"];
var akanFemale = ["Akosua","Adwoa","Abenaa","Akua","Yaa","Afua","Ama"];
var month = parseInt(document.getElementById("month").value);
var year = parseInt(document.getElementById("year").value);
var day = parseInt(document.getElementById("day").value);
var dateOfBirth = new Date(year + "/" + month + "/" + day);
document.getElementById("para").innerHTML = dateOfBirth
var results = dateOfBirth.getDay();
var output = document.getElementById("output");
var male = document.getElementById("male")
var female = document.getElementById("female")
if (month =="" && year =="" && day =="") {
alert("PLease Fill The Form")
return false;
}
if (year < 0) {
output.style.background ="blue"
output.style.color= "white"
output.innerHTML = " invalid year! "
}
else if ((month < 1) || (month > 31)) {
output.style.background ="blue"
output.style.background ="white"
output.innerHTML = "invalid month!"
}
else if ((day < 0 ) || (day > 31)) {
output.style.background ="blue"
output.style.background ="white"
output.innerHTML = "invalid day!"
}
if(male.checked && year > 0 && month > 0 && month < 12 && day > 0 && day < 32) {
output.style.background ="yellowgreen"
output.innerHTML = "You were born on a " + daysOfTheWeek[results] + " and your Akan name is " + maleNames[results];
}
else if(female.checked && year > 0 && month > 0 && month < 12 && day > 0 && day < 32) {
output.style.background ="yellowgreen"
output.innerHTML = " You were born on a " + daysOfTheWeek[results] + " and your Akan name is " + femaleNames[results];
}
}