The javascript is ok, except for ToString
as Daryl already pointed out.
I would add a check for height
and weight
to prevent null values (the check if is a positive number can be avoided if the fields have a minimum value setting greater than 0.00)
function BMICheck()
{
var weight = Xrm.Page.getAttribute("new_weight").getValue();
var height = Xrm.Page.getAttribute("new_height").getValue();
if (weight != null & height != null) {
var bmi = weight/(height/100*height/100);
Xrm.Page.getAttribute("new_bmi").setValue(Math.round(bmi*100)/100);
}
else {
alert("Need to insert Weight and Height!");
}
}