-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (34 loc) · 1.17 KB
/
Copy pathscript.js
File metadata and controls
43 lines (34 loc) · 1.17 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
function compute()
{
var principal = document.getElementById("principal").value;
var rate = document.getElementById("rate").value;
var years = document.getElementById("years").value;
var x = document.createElement("MARK");
//principal * years * rate / 100;
var amount = principal * years * rate /100;
var year = new Date().getFullYear()+parseInt(years);
function marks(y) {
var x = document.getElementById("highlight");
//x=y;
x.innerHTML=y;
return x.innerHTML;
}
//Check if Amount field is empty
if(principal== ""){
alert("Please enter the Amount");
document.getElementById("result").innerHTML.focus();
return false;
}
//Check if Amount value 0
else if (principal<=0){
alert("Please enter the valid number, Amount must be positive and nonzero");
document.getElementById("result").innerHTML.focus();
return false;
}
//If all is well return true.
else
{alert("validation is successful.")
//return true;
document.getElementById("result").innerHTML="If you deposit "+marks(principal)+",\<br\>at an interest rate of "+rate+"%\<br\>You will receive an amount of "+amount+",\<br\>in the year "+year+"\<br\>";
}
}