limiting characters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:17 AM
Hello,
I've implemented a catalog onchange client script that effectively limits users to entering a maximum of 10 characters, which is functioning well. Presently, an alert is triggered only when a change or action is performed on the form. However, I'm seeking a solution that prevents users from typing more than 10 characters in the first place. Could you provide guidance on how to achieve this? I want the field to immediately block any further input after reaching the 10-character limit.Thank you for your assistance.
function onChange() {
var field = 'short_description';
var value = g_form.getValue(field);
if (value.length > 10)
alert('The short description has exceeded the maximum character limit of 10 characters. Please ensure that the text length is within the allowed range.');
return false;
}
}
Regards,
Priyanka

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:24 AM
Hi @PK14,
It is not needed to do this with a client script.
Add a variable attribute: max_length=10
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:27 AM
Hi @PK14
Click on configure variable.Goto default Value tab-->in variable attribute field add below.
max_length=10
This will solve your issue.
Please mark Helpful, Like, or Correct Answer if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:35 AM
Hi @PK14 ,
You can either use Field validation: Regular Expressions or Add a variable attribute: max_length=10.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:55 AM
HI @PK14,
You can achieve this by using max_length attribute in service catalog variable.
max_length Sets the maximum number of characters allowed in the field. By default, the field accepts long strings of text, several thousand characters. Set the max_length attribute as appropriate for the information that the variable is collecting. For example, to allow for entry of an address, set max_length=200, or other appropriate length.
Applicable variables: Single-line text, Wide single-line text
This worked fine in my case, it will not allow any character to be entered after 10 characters. Refer beow:
Please mark it Correct and Hit Like if you find this helpful!
Regards,
Karthiga