Can we set a limit on Integer Input Variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2016 12:29 PM
Hi,
I have a field on my custom form called working days. It is an Integer type variable. I have to restrict it to be put between 220 - 365.
Is there any way to be able to set a limit on Integer input variables? We can restrict the input by OnChange Client Script but is there any other fundamental way to do it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2016 01:12 PM
I think onchange client script is the only way to do that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2016 01:15 PM
Hi Arnab,
You are correct. The onChange client script is going to be the best way to approach this. There is nothing built in to the platform to help automate this for you. Your onChange script would look something like this (WARNING: Untested)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
g_form.hideFieldMsg('u_working_days');
var newVal = parseInt(newValue, 10);
if (newVal < 200 || newVal > 365) {
g_form.showFieldMsg('u_working_days', 'Values must be between 220 and 365', 'error');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2017 07:07 AM
Hi Chuck,
I've just tried to add the above for a new field I have. We only want the user to be able to add numbers 1-25. I've used the above with my amendments:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
g_form.hideFieldMsg('u_risk_based_testing_score');
var newVal = parseInt(newValue);
if (newVal < 1 || newVal > 25) {
g_form.showFieldMsg('u_risk_based_testing_score', 'Values must be between 1 and 25', 'error');
}
}
If I enter values 1 - 25 these are fine. The error message then appears for values 26 - 999.
Then values 1,000 - 25,999 these do not show the error, then numbers 26,000 and above do.
Do you know what would cause this?
Alternatively is there a way to stop users adding more than 2 digits into the integer field?
Thanks
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 07:41 AM
Hi Sam,
Try this with your parseInt() statement.
var newVal = parseInt(newValue, 10);
As for stopping after a number of characters, not that I'm aware on an integer field. A string field of length 2, perhaps.