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:56 AM
Hi @Ratnakar7 @Nilesh Pol1 @Peter Bodelier
I already tried the max_length=10 thing but it doesn't work. User is still able to add more then 10 values.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 06:00 AM
Please add a screenshot of the variable, with that attribute added.
Other option is to use Regex validation of course.
I wouldn't do this with a client script. This is not fool proof.
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 07:39 AM
Make sure that the type of the variable is Single-line text or Wide single-line text. Else, it will not work.
Please mark it Correct and Hit Like if you find this helpful!