ora 8 9
This commit is contained in:
26
ora7/roxfort.js
Normal file
26
ora7/roxfort.js
Normal file
@@ -0,0 +1,26 @@
|
||||
function calculateYearsSince(dateString) {
|
||||
const date = new Date(dateString);
|
||||
const diff = Date.now() - date.getTime();
|
||||
return new Date(diff).getUTCFullYear() - 1970;
|
||||
}
|
||||
|
||||
console.log(calculate2("2001-09-01"));
|
||||
|
||||
const form = document.getElementById('hogwarts-form');
|
||||
form.dateofbirth.addEventListener("input", function(event){
|
||||
console.log(form.dateofbirth.value);
|
||||
const age = calculateYearsSince(form.dateofbirth.value);
|
||||
console.log(age);
|
||||
|
||||
if(age >= 11){
|
||||
form.dateofbirth.setCustomValidity('');
|
||||
}else{
|
||||
form.dateofbirth.setCustomValidity('young');
|
||||
}
|
||||
})
|
||||
|
||||
form.house.addEventListener('change', function (event){
|
||||
const houseColor = form.house.options[form.house.selectedIndex].dataset.colorPrimary;
|
||||
console.log(houseColor);
|
||||
document.body.style.backgroundColor = houseColor;
|
||||
})
|
||||
Reference in New Issue
Block a user