	function checkNumber(input, min, max, msg) {		msg = "The " + msg + " field is invalid. ";		//this makes sure that the number is a number		var str = input.value;		for (var i = 0; i < str.length; i++) {			var ch = str.substring( i, i + 1)			if ((ch < "0" || "9" < ch) && ch != '.') {				alert(msg);				return false;			}		}		//this makes sure that the number lies between the min and max values allowed		var num = 0 + str		if (num < min || max < num) {			alert(msg + "The figure should be between " + min + " and " + max + ".");			return false;		}		input.value = str;		return true;	}	function computeField(input) {		if (input.value != null && input.value.length != 0)		{			input.value = "" + eval(input.value);		}		computeForm(input.form);		//clearForm(input.form);		return false;	}	function computeForm(form) {		var A=form.A.value; // Principal amount		var T=form.T.value; // Term - number of years		var R=form.R.value; // Rate of interest		//making sure that an entry has been made in each field.		if ((A == null || A.length == 0) ||			(R == null || R.length == 0)) 		{			//alert('not all fields filled in');			return;		}		// making sure that entries are valid by using check number		if (!checkNumber(form.A, 1, 99999999, "'Mortgage required'") ||			!checkNumber(form.R, .001, 1000, "Interest rate") ||			!checkNumber(form.T, 5, 40, "Repayment period")) 		{			form.Cm.value = "Invalid";			return;		}		// maths et al to be computed		R = R / 100;		var P = ((A*R)/12) * (1/(1-(Math.pow(1/(1+R),T))));		form.Cm.value = poundsPence( P );		P = ((A*0.12)/12) * (1 / (1-(Math.pow((1/1.12),T))));		//form.CCm.value = poundsPence( P );		P = (A*R)/12;		form.CI.value = poundsPence( P );		P = ((A*0.12)/12);		//form.CCI.value = poundsPence( P );		return false;	}	function poundsPence( N ) {		// won't work as intended in ie3		if ((navigator.appName.indexOf('Microsoft')>-1)			&& (navigator.appVersion.indexOf('3.0')>-1) )		{			return N;		}		S = new String( N );		var i = S.indexOf('.');		if (i != -1) {			S = S.substr( 0, i+3 );			if (S.length-i < 3)				S = S + '0';		}		return S;	}	//clears form	function clearForm(form) {				form.A.value = "";		form.T.value = "";		form.R.value = "";				form.Cm.value = "";		form.CI.value = "";		return false;	}