- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 07:46 PM
Hi All, I have a integer field type . In that I need to restrict user to enter only few values like , 10,30,40. If the user try to enter any other values it should throw error .. any one help me with these work around here . Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 10:27 PM
Hi,
Just add one more line as shown below:
g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');
g_form.clearValue('field_name');
// this will clear value , hope your field is mandatory so user won't be able to submit form with empty field
Or use same logic in on submit client script and instead of clear value use below:
g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');
return false;
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 08:03 PM
Hi Vinay,
You can write an On Change type client script, which will run on that integer type field.
In the script you can have the validation as
if (g_form.getValue('<integer_field_name>') == 10 || g_form.getValue('<integer_field_name>') == 30 || g_form.getValue('<integer_field_name>') == 40) {
g_form.showFieldMsg('<integer_field_name>','Error Message: The entered value is not allowed','error');
}
This will add the validation to the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 08:44 PM
Hi K9,
Thanks for your reply but as I tried , given on change client script is not working.. it's unable to validate values and accepting the all integers although I have given 10 and 20 to be taken..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 08:56 PM
Can you please share screenshot of your client script?
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-03-2022 09:06 PM
Please try below logic:
if (g_form.getValue('field_name') != 10 && g_form.getValue('field_name') != 30 && g_form.getValue('field_name') != 40) {
g_form.showFieldMsg('field_name','Error Message: The entered value is not allowed','error');
}
Make sure client script is of type on Change and field selected is your integer field.
Thanks,
Anil Lande
Thanks
Anil Lande