How can I check if an input number falls within a specified range? I need to display if it is within the range, higher, or lower than the acceptable range.
My current Javascript code seems to be causing an error message stating it is an invalid entry.
It should be able to handle decimal places, as the range values are user-defined.
var highRange = 17.80;
var lowRange = 6.90;
var valueToCheck = (rText.value);
function checkRange() {
var msg = 'Invalid entry';
if ((valueToCheck > 0.00) && (valueToCheck <= lowRange)) { msg = 'LOW'; }
if ((valueToCheck > lowRange) && (valueToCheck <= highRange)) { msg = 'NORMAL'; }
if ((valueToCheck > highRange)) { msg = 'HIGH'; }
rangeValue = msg;
}
I'm puzzled as to why it's not functioning properly, haha.
Any assistance would be greatly appreciated :-)