Skip to content
Merged

Root71 #2204

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}

var maxChars = 100;//count of charaters
var currentLength = newValue.length;

// Clear previous messages
g_form.clearMessages();

// Show info message
g_form.addInfoMessage('Character count: ' + currentLength + ' / ' + maxChars);

if (currentLength > maxChars) {
// Show error message
g_form.addErrorMessage('Character limit exceeded! Please shorten your text.');
g_form.showFieldMsg('short_description', 'Too many characters!', 'error');

// Make field mandatory to block submission
g_form.setMandatory('short_description', true);
} else {
// Remove mandatory if valid
g_form.setMandatory('short_description', false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This onChange Catalog Client Script displays the current character count for a text field and enforces a maximum limit by showing error messages and making the field mandatory to prevent form submission when exceeded.
Loading