1 Stop Mortgage Calculator - Calculate your Mortgage payments in Seconds!
Mortgage Calculator Code - Part 1 - Introduction. Mortgage calculator formula

# Mortgage calculator code

##### Part 1 Introduction - The mortgage formula

When you want to create a web page that contains a mortgage calculator, finding the correct JavaScript mortgage code is not easy. First, you need the basic mortgage formula. And then, once you have the formula, you have to program it in JavaScript. All this is not easy, and at the same time, it's easy once we know the loan formula... or we think it is!

Programming JavaScript is more behind de scene than up front for your website visitors, but it's fascinating if you like to program. For those of you who think that you must program a loan calculator in Java, Perl or C++, well... it can be done with JavaScript. If you are web designers, webmasters, real estate agents or JavaScript programmers looking for mortgage calculator code, keep on reading:

##### The heart of the calculator code is the mortgage formula:

Pa = PrValue x IntRate / (1 – (1 + IntRate)–Period)

Where Pa is the payment, PrValue the present value of the loan, IntRate the interest rate and Period, the number of years you are borrowing the money.

Knowing the mortgage formula is one thing. It's all the other details that make it hard to do... form validation, input transformation, etc. Therefore, it's not that easy to program a JavaScript mortgage calculator... because a lot of small details are involved.

For a very basic example of code that you can use right away, go to this JavaScript mortgage calculator page.

As I said earlier, it's easy and at the same time it's not easy.

It would be easy if all we had to do was to program the mortgage formula in JavaScript. Much more is involved than just the formula code. In order to code a good calculator, you also need sub-routines that validate the entered data, that show the results with the good values (2 decimal places, percent sign), etc. It's mainly a question of interface and data validation.

In part 2 of this mortgage calculator code series you will discover:

How do we code the mortgage formula? The basic JavaScript mortgage formula code and more.