Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 4eff688

Browse files
committed
shortened
1 parent a453a12 commit 4eff688

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/FormPage/FormPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const TextareaWordCountingWidget = (props) => {
119119
} = props;
120120

121121
const showWordCount = !!schema.word_count;
122-
const wordCount = value.split(/[\s]+/).filter(function (el) {return el !== '';}).length;
122+
const wordCount = value ? value.split(/[\s]+/).filter(el => el !== '').length : 0;
123123

124124
const _onChange = ({ target: { value } }) => {
125125
return onChange(value === "" ? options.emptyValue : value);
@@ -183,7 +183,7 @@ function validate(formData, errors, schema) {
183183
.filter((key) => !!schema.properties[key].word_count)
184184
.forEach((key) => {
185185
const wordCount = schema.properties[key].word_count;
186-
if (formData[key] && formData[key].split(/[\s]+/).filter(function (el) {return el !== '';}).length > wordCount) {
186+
if (formData[key] && formData[key].split(/[\s]+/).filter(el => el !== '').length > wordCount) {
187187
errors[key].addError(`Response cannot exceed ${wordCount} words`);
188188
}
189189
});

0 commit comments

Comments
 (0)