forked from khushi-purwar/WebDev-ProjectKart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
23 lines (21 loc) · 774 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const form = document.querySelector('form');
form.addEventListener('submit', function(e){
let feet =document.querySelector('#feet');
let inches = document.querySelector('#inches');
const results = document.querySelector('#results');
e.preventDefault();
feet =parseInt(feet.value);
inches=parseInt(inches.value);
if(isNaN(feet)||isNaN(inches)){
results.textContent="Please enter valid number!";
}
else if(feet<0){
results.textContent="Please enter an inche value between 0 and 12";
}
else{
let totalInches =(feet*12)+inches;
results.textContent=`${totalInches}cm`;
document.querySelector('#feet').value='';
document.querySelector('#inches').value='';
}
})