<!--Hide JavaScript from Java-Impaired Browsers
function toInteger(field,checkString)
{
    newString = "";    // REVISED/CORRECTED STRING
    count = 0;         // COUNTER FOR LOOPING THROUGH STRING

    // LOOP THROUGH STRING CHARACTER BY CHARACTER
    for (i = 0; i < checkString.length; i++)
	{
        ch = checkString.substring(i, i+1);

        // ENSURE CHARACTER IS A DIGIT
        if (ch >= "0" && ch <= "9")
		{
            newString += ch;
        }
    }
	
	if (checkString != newString)
	{
		alert("Please use only numeric values for the " + field.name + " field.");
		field.focus();
	}

    return newString;
}

function computeForm(form)
{
	if ((!form.age.value || form.age.value.length==0) ||
    	(!form.restingrate.value || form.restingrate.value.length==0))
	{
		alert("Please enter in a value for both your age and resting heart rate.");
		return;
	}
//	if (!alrt_msg(form.age,7,105,"Your Age"," ") ||
//    	!alrt_msg(form.restingrate,20,110,"Your Resting Heart Rate","Retake your Resting Heart Rate or see your physician."))
//	{
//		return;
//    }
	var	age = 1 * form.age.value;
	var restingrate = 1 * form.restingrate.value;
	var maxhr = 220 - age;
	var sedthr = Math.round(.5 * (maxhr - restingrate) + restingrate);
	var inactivethr = Math.round(.6 * (maxhr - restingrate) + restingrate);
	var activethr = Math.round(.7 * (maxhr - restingrate) + restingrate);
	var vactivethr = Math.round(.8 * (maxhr - restingrate) + restingrate);
	form.maxhr.value = maxhr;

	form.sedthr.value = sedthr;
	var lo = Math.round(.9 * sedthr);
	var hi = Math.round(1.1 * sedthr);
	form.sedthrrange.value = lo + " to " + hi;
	lo = Math.floor(sedthr / 10);
	form.sedmanrange.value = lo + " to " + ++lo;

	form.inactivethr.value 	= inactivethr;
	lo = Math.round(.9 * inactivethr);
	hi = Math.round(1.1 * inactivethr);
	form.inactivethrrange.value = lo + " to " + hi;
	lo = Math.floor(inactivethr / 10);
	form.inactivemanrange.value = lo + " to " + ++lo;

	form.activethr.value 	= activethr;
	lo = Math.round(.9 * activethr);
	hi = Math.round(1.1 * activethr);
	form.activethrrange.value = lo + " to " + hi;
	lo = Math.floor(activethr / 10);
	form.activemanrange.value = lo + " to " + ++lo;

	form.vactivethr.value 	= vactivethr;
	lo = Math.round(.9 * vactivethr);
	hi = Math.round(1.1 * vactivethr);
	form.vactivethrrange.value = lo + " to " + hi;
	lo = Math.floor(vactivethr / 10);
	form.vactivemanrange.value = lo + " to " + ++lo;
}
 
function alrt_msg(entry,low,high,prompt,trail)
{
//	prompt= prompt + " entry has unacceptable stuff: "+entry.value;
	var scratch=entry.value;
	for (var i=0;i<scratch.length;i++)
	{
		var letter=scratch.substring(i,i+1);
		if ((letter<"0" || "9"<letter) && letter!='.')
		{
			alert(prompt);
			return false;
		}
    }
	var errtst=parseFloat(scratch)
	if (errtst<low || high<errtst)
	{
		alert(prompt + " should be in the range"
			+" from "+low+" to "+high+"." + "\n" + trail);
		return false;
	}
	entry.value=scratch;
	return true;
}
<!-- end of script -->

