function ValueLimit(min, max, mode){
var v;
if(mode === "h"){
v = document.getElementById("weight_imp").value;
if(v < min){document.getElementById("weight_imp").value = min;}
if(v > max){document.getElementById("weight_imp").value = max;}
}
if(mode === "w"){
v = document.getElementById("weight_imp").value;
if(v < min){document.getElementById("weight_imp").value = min;}
if(v > max){document.getElementById("weight_imp").value = max;}
}
}
I need to replace mode with an ID of an input element This should in turn make the code significantly smaller I cannot seem to find a way to pass it through It should be able to target any element on the page