Skip to content

Commit 5446345

Browse files
committed
changed hideFieldMsg to clearMessages
1 parent 45cbfe1 commit 5446345

File tree

1 file changed

+8
-8
lines changed
  • Client-Side Components/Client Scripts/field word counter

1 file changed

+8
-8
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
function onChange(control, oldValue, newValue, isLoading) {
22
if (isLoading) return;
3-
3+
44
// USER CONFIGURATION: Set field name and word limit
55
var fieldName = 'short_description'; // Change to your field name
66
var maxWords = 25; // Change to your word limit
7-
7+
88
var trimmedValue = newValue ? newValue.trim() : '';
99
var currentWords = trimmedValue ? trimmedValue.replace(/\s+/g, ' ').split(' ').length : 0;
10-
10+
1111
// Clear any existing messages
12-
g_form.hideFieldMsg(fieldName);
13-
12+
g_form.clearMessages();
13+
1414
// Show appropriate message based on word count
1515
if (currentWords > maxWords) {
16-
g_form.addErrorMessage(fieldName, currentWords + ' out of ' + maxWords + ' words - Limit exceeded', ' error');
16+
g_form.addErrorMessage(fieldName + ' ' + currentWords + ' out of ' + maxWords + ' words - Limit exceeded', ' error');
1717
} else if (currentWords >= maxWords - 5) {
18-
g_form.addInfoMessage(fieldName, currentWords + ' out of ' + maxWords + ' words - Approaching limit', ' warning');
18+
g_form.addInfoMessage(fieldName + ' ' + currentWords + ' out of ' + maxWords + ' words - Approaching limit', ' warning');
1919
} else {
20-
g_form.addInfoMessage(fieldName, currentWords + ' out of ' + maxWords + ' words', ' info');
20+
g_form.addInfoMessage(fieldName + ' ' + currentWords + ' out of ' + maxWords + ' words', ' info');
2121
}
2222
}

0 commit comments

Comments
 (0)