OnChange script is not working for HTML type variable in the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 04:17 AM
Hi All,
I have a variable set in which there is a HTML type variable.
I have to restrict the characters limit to 32,767.
This the script:
alert("OnChange client script ") ;
var desc= g_form.getValue('description');
if (desc.length > 32767) {
alert("You cannot enter more than 32767 characters.");
return false;
}
I just added alert, but onChange script in not working.
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 05:22 AM
Hello @Samiksha2 ,
The script works fine on my end. I hope you have not removed the onChange function that needs to surround it. Please also note that onChange Client Scripts will only run when you move the focus to the next field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert("OnChange client script ");
var desc = g_form.getValue('description');
if (desc.length > 32767) {
alert("You cannot enter more than 32767 characters.");
return false;
}
}
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 05:28 AM - edited 04-11-2025 05:29 AM
Hi @Robert H ,
Yes, I am doing the same. 1st alert is also on coming.
This is the variable in the variable set
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 09:56 AM
Hello @Samiksha2 ,
In your first post the variable name mentioned in the script was "description", but in your more recent screen shots it's "html_description". What's the actual name?
No matter, let's do some simple troubleshooting. Please verify that you have the following things present on your Catalog Item, and nothing else that could interfere:
- your HTML variable, either directly related to the Catalog Item or part of a Variable Set
- an onChange script where the selected "Variable name" is the above HTML variable, and the Client Script is either part of the above Variable Set or related directly to the Catalog Item
- the onChange script contains the following:
if (newValue.length > 5) {
alert('...');
}
If this is the case then this will definitely work, you will get the alert after typing more than 5 characters and then leave the input field's focus. If any of the above is not the case then please adjust accordingly.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 02:32 AM
Hi @Robert H ,
I tried. nothing worked. so I changes the Onchange to Onsubmit. Now it is working.
Thanks,
Sam