Skip to content

Commit

Permalink
Fix word count when text is pasted and spaces are converted to to non…
Browse files Browse the repository at this point in the history
…-breaking spaces ( )
  • Loading branch information
DaniBitZesty committed Jul 15, 2024
1 parent 3882a99 commit 3ae429b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ window.FormValidation =

validateWordLimit: (question) ->
wordLimit = $(question.context).attr("data-word-max")
wordCount = $(question.context).val().split(" ").length
normalizedContent = $(question.context).val().replace(/ /g, ' ');
wordCount = normalizedContent.split(" ").length
if wordCount > wordLimit
@logThis(question, "validateWordLimit", "Word limit exceeded")
@addErrorMessage(question, "Exceeded #{wordLimit} word limit.")
Expand Down

0 comments on commit 3ae429b

Please sign in to comment.