js计算车贷还款金额代码
js计算车贷还款金额怎么算,js计算车贷还款金额代码教程如下:
输入贷款金额和利率
计算结果:计算出每月应还贷款金额和贷款总额
js实现代码:
// JavaScript Document//鏁版嵁鏍煎紡楠岃瘉
function CheckElem(curObj, msg) {
if (msg == null) msg = "";
if (curObj.val() == '') {
alert(msg + "\u4e0d\u80fd\u4e3a\u7a7a!");
curObj.focus();
curObj.select();
return false;
}
else if (isNaN(curObj.val())) {
alert(msg + "\u5fc5\u987b\u4e3a\u6570\u5b57!");
curObj.focus();
curObj.select();
return false;
}
else if ((isNaN(curObj.val())) || (curObj.val().indexOf("-") != -1)) {
alert(msg + "\u8bf7\u8f93\u5165\u6b63\u6570!");
curObj.focus();
curObj.select();
return false;
}
else if ((isNaN(curObj.val())) || (curObj.val() == 0)) {
alert(msg + "\u4e0d\u80fd\u4e3a\u96f6");
curObj.focus();
curObj.select();
return false;
}
else {
return true;
}
}
//璐锋骞撮檺楠岃瘉
function IsIntYear(curObj, msg) {
if (msg == null) msg = "";
v = curObj.val();
var vArr = v.match(/^[0-9]+$/);
if (v > 30) {
alert(msg + "\u6700\u957f\u4e0d\u80fd\u8d85\u8fc730\u5e74!");
curObj.focus();
curObj.select();
return false;
}
else if (vArr == null) {
alert(msg + "\u8bf7\u586b\u5199\u6574\u6570!");
curObj.focus();
curObj.select();
return false;
}
else {
return true;
}
}
//閲戦楠岃瘉
function IsIntAmount(v, type, msg) {
if (msg == null) msg = "";
if (v > 10000000 && type == 1)//璐锋璐圭敤
{
alert(msg + "\u6700\u9ad8\u4e0d\u80fd\u8d85\u8fc71000\u4e07\u5143!");
return false;
}
else if (v > 50 && type == 3)//璐锋鍒╃巼
{
alert(msg + "\u6700\u9ad8\u4e0d\u80fd\u8d85\u8fc750%!");
return false;
}
else {
return true;
}
}
function Format(myFloat) {
return Math.round(myFloat * 100) / 100;
}
显示效果:车贷款计算器
参考文章:http://www.theicstock.com/gonglve/1020.html