bzingler Posted October 21, 2013 Share Posted October 21, 2013 // JavaScript Document$(document).ready(function(){//declare variables function calculate(){ var weight, height, bmi; weight= $('#weight').val(); height= $('#height').val(); //calculate total bmi = weight*703/(height*height); bmi = bmi.toFixed(1); $('#bmi').val(bmi); if (bmi < 18.5){ $('#bmi_message').html('Your BMI shows you are under weight.'); } if (bmi >= 18.5 && bmi <= 24.9){ $('#bmi_message').html('Your BMI shows you are a normal weight.'); } if (bmi >= 25 && bmi <= 29.9){ $('#bmi_message').html('Your BMI shows you are over weight.'); } if (bmi > 30){ $('#bmi_message').html('Your BMI show you are obese.'); } return false;}//end of calculate function $('#bmiform').submit(calculate); $('#bmiform').validate({ rules: { }, messages:{ height: "Please enter a valid height between 24 in. and 100 in.", weight: "Please enter a valid weight between 20 lb. and 500 1b." } }); return false; });I am trying to get this so that it does not calculate unless the form is validated. Not sure what I am doing wrong. Link to comment Share on other sites More sharing options...
Larry Posted October 22, 2013 Share Posted October 22, 2013 What's the HTML form look like? What, if any, errors are you seeing? What is working? What isn't working? What's happening that shouldn't? What isn't happening that should? In short: give us more to go on here. Link to comment Share on other sites More sharing options...
Recommended Posts