How to set minimum character length for a multi-line text variable in a catalog item

Community Alums
Not applicable

Can anybody tell me how I set the minimum character length to 50 characters in a multi-line variable in a catalog item?

The variable itself is already mandatory but I don't want people to write just "because I want it" or other pointless answers down.

 

Add on: I probaply chose the wrong Location for that question, could someone tell me where to locate this question right?

 

 

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, you could look at onChange client script using string length to validate the field content and popup a message if minimum requirements were not met; But I don't see this as a practical configuration as it may force users to enter 'garbage' in order to be able to submit the form.
A better solution would be field message, text, tool tip, popup to clearly identify expectations
and then a clearly defined business process that deals with requests that do not have appropriate details IE process of rejecting any requests that do not meet minimal expectations.

View solution in original post

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, you could look at onChange client script using string length to validate the field content and popup a message if minimum requirements were not met; But I don't see this as a practical configuration as it may force users to enter 'garbage' in order to be able to submit the form.
A better solution would be field message, text, tool tip, popup to clearly identify expectations
and then a clearly defined business process that deals with requests that do not have appropriate details IE process of rejecting any requests that do not meet minimal expectations.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Community Alums ,
I trust you are doing fine.
You can achive this by creating onChage client script

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) {
        return;
    }
    
    if (control.id === 'YOUR_VARIABLE_NAME' && newValue.length < 50) {
        g_form.addErrorMessage('Please enter at least 50 characters.');
        g_form.clearValue('YOUR_VARIABLE_NAME');
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Community Alums
Not applicable

Hi @Tony Chatfield1,

you're right! 50 chars are way too much regarding your point. We have to decide if we lower that number or leave it totally out. We already have the tooltip pop up active, so we have to see what input we'll get.

Community Alums
Not applicable

Hi @Amit Gujarathi 

unfortunately your script doesn't work when i copy-paste that and insert my variable. But with your answer you confirm what Tony said. So I'll have to find a way myself with the client script, but it's great learning opportunity.

 

All the best!