JavaScriptケース:住宅ローン計算機
6566 ワード
データテーブル
A B C
70000.00 /
382.50 / /
50.50 / /
200
40% ( )
4%
5600000.00 :B1*B4*B5
8400000.00 :B1*B4*(100%-B5)
28000.00 / :B9*B6/12
76500.00 / :B2*B4
10100.00 / :B4*B3
//
//
// :1.
//2. test.js house.js( )
//3.
//
:
:
:
:
:
.init{
background: #F5F5F5;
font-weight: bold;
color: #000000;
}
.wrong{
background: #F5F5F5;
font-weight: bold;
border:1px #FF0000 solid;
color: #000000;
}
.right{
background: #F5F5F5;
font-weight: bold;
border:1px #00FF00 solid;
color: #000000;
}
.title{
font-weight: bold;
font-size: 26px;
}
window.onload=function(){
document.getElementById("unitprice").addEventListener("blur",validateUnitprice,false);
document.getElementById("rent").addEventListener("blur",validateRent,false);
document.getElementById("cost").addEventListener("blur",validateCost,false);
document.getElementById("area").addEventListener("blur",validateArea,false);
document.getElementById("interest").addEventListener("blur",validateInterest,false);
var trElement=document.all("tabRow");
for(var x=0;x
function validateEmpty(eleName){
var obj =document.getElementById(eleName);
var msg =document.getElementById(eleName+"Msg");
if (obj.value!="") {
obj.className="right";
if (msg!=null) {
msg.innerHTML=" !";
}
return true;
}else{
obj.className="wrong";
if (msg!=null) {
msg.innerHTML=" !";
}
return false;
}
}
function validateRegex(eleName,regex){
var obj =document.getElementById(eleName);
var msg =document.getElementById(eleName+"Msg");
if (regex.test(obj.value)) {
obj.className="right";
if (msg!=null) {
msg.innerHTML=" !";
}
return true;
}else{
obj.className="wrong";
if (msg!=null) {
msg.innerHTML=" !";
}
return false;
}
}
function changeColor(obj,color){
obj.bgColor=color;
}
//
function round(num,scale){
var result=Math.round((num*Math.pow(10,scale)))/(Math.pow(10,scale));
return result;
}