Issue T10913
Visible to All Users

Creator - Question Title Charactor Limit

created 3 years ago (modified 3 years ago)

We are currently trying to accomplish the following when adding a new Question - we want to limit the character count.

In the Creator,
prevent the question title being more than 50 chars long in the Designer ( When adding a question ).
prevent the question title being more than 50 chars long in the General tab ( Right of screen ).

Note: we are not showing the validation expressions as we have hidden them from view.

General tab,
Wont allow more than 50 chars in the title field ( Correct )
Copy and paste more than 50 chars into the field, it will cut off anything after 50 chars ( Correct )

Designer,
Wont allow more than 50 chars in the title field ( Correct )
Copy and paste more than 50 chars into the field, it will NOT cut off anything after 50 chars ( Wrong )

"survey-core": "^1.9.52",
"survey-creator-react": "^1.9.52",
"survey-react": "^1.9.52",

This is what we are using to limit the charactors

TypeScript
var maxTitleLength = 50; SurveyCreator. onPropertyValueChanging .add((_sender, options) => { if(options.propertyName=="title"){ if(options.newValue.length >= maxTitleLength){ options.newValue = options.newValue.slice(0,maxTitleLength-1); options.value = options.newValue.slice(0,maxTitleLength-1); } // if null, or whitespace, then reset to name if(options.newValue.length == 0 || options.newValue.match(/^ *$/) !== null){ options.newValue = options.obj.name; options.value = options.obj.name; } } });
Comments (1)

    Hello Johnny,
    The onPropertyValueChanging event is raised when changing object properties via the Property Grid only. It is not raised when changing the Title property from the design surface. We will further research this issue and post updates in the following thread: V2: If title entered through the inplace editor the onPropertyValueChanging event is not fired.

    Answers approved by surveyjs Support

    created 3 years ago

    Hello Johnny,
    We've fixed this issue. With v1.9.54 and newer, the creator.onPropertyValueChanging event is raised when users update survey properties via the design surface. You can use this event to correct a title value: example.

    Should you have any questions or require further assistance, we are here to help.

    Thank you