- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:11 AM
Hi All,
How to set character limit for a variable. It should request you to enter a minimum of 8 characters to max limit. Allow up to 100 characters (w/spaces).
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:34 AM
Hi,
Please write a On Change Catalog Client Script on your variable and use the script below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue) {
var myFieldValue = g_form.getValue('Variable Name');
if (myFieldValue.toString().length < 3) { // or whatever number you want
g_form.setValue('your_field', '');
alert('Please enter 3 or more characters.');
}else if(myFieldValue.toString().length > 100){
g_form.setValue('your_field', '');
alert('Please enter less than 100 characters.');
}
}
//Type appropriate comment here, and begin script below
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:26 AM
You can use Regular Expressions to handle this
/^.{1,10}$/.test(variable) // min - 1, max - 10
Mark helpful/correct if this resolved your query.
Regards
Vinayak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:34 AM
Hi,
Please write a On Change Catalog Client Script on your variable and use the script below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue) {
var myFieldValue = g_form.getValue('Variable Name');
if (myFieldValue.toString().length < 3) { // or whatever number you want
g_form.setValue('your_field', '');
alert('Please enter 3 or more characters.');
}else if(myFieldValue.toString().length > 100){
g_form.setValue('your_field', '');
alert('Please enter less than 100 characters.');
}
}
//Type appropriate comment here, and begin script below
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke