I have managed to get my fields to calculate properly but now I am trying to add some validation to them which is proving difficult. What I aim to do is make sure that the fields have to contain numbers only and have to be filled in.
function audience_details()
if(fields.length === 0) {
var aud1, aud2, total;
var aud1 = parseInt(document.getElementById("audience_1_field").value);
var aud2 = parseInt(document.getElementById("audience_2_field").value);
var reach = parseInt(document.getElementById("reach_field").value);
var total = (aud1 + aud2 - reach ) / aud1 * 100 ;
total_field.value = parseFloat(total).toFixed(2) + '%';
estimate.value = parseFloat(total).toFixed(2) + '%';
}
else {
//alert fields must be complete / contain numbers only!
}
any help would be lovely here is the form http://jsfiddle.net/pjf2v7b8/