Hello all,
Just a quick disclaimer: I have zero JavaScript experience so it is probably a stupid mistake I'm making. I apologise in advance.
I'm trying to check several textinputs to make sure that there is a number entered and it is within a specific range. The range will be different on each field and can include up to one decimal.
I have added a function to the to javascript file that looks like this:
function validateInRange(str, min, max) {
n = parseFloat(str);
return(!isNaN(n) && n >= min && n <= max);
}
and on the first field I want to validate, with the short name "Neck" I have this code in the Advanced Field Options -> Client Side Event:
function validateFieldRange()
if(!validateInRange($(Neck), 10, 20)) {
alert("Please enter a value between 10 and 20");
return false;
}
}
I also tried without the function:
if(!validateInRange($(Neck), 10, 20)) {
alert("Please enter a value between 10 and 20");
return false;
}
The code is appearing in the rendered form HTML but it is not being called and not generating the alert or any error.
I have enabled client side validation in the form configuration.
Can anyone suggest what steps to take to get this to work? Or another solution to my problem would be great. If there is a simpler way than this JavaScript to check a field for a number and within a certain range.
All help is greatly appreciated!