File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Client-Side Components/Client Scripts/field word counter Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 11function 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}
You can’t perform that action at this time.
0 commit comments