Skip to content

Commit

Permalink
Fix textarea step validation
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniBitZesty committed Jul 15, 2024
1 parent 3ae429b commit 911b746
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ window.FormValidation =
return question.find("input[type='checkbox']").filter(":checked").length

validateWordLimit: (question) ->
wordLimit = $(question.context).attr("data-word-max")
normalizedContent = $(question.context).val().replace(/ /g, ' ');
textarea = question.find("textarea")
wordLimit = textarea.attr("data-word-max")
normalizedContent = textarea.val().replace(/ /g, ' ').replace(/\n/g, ' ');;
wordCount = normalizedContent.split(" ").length
if wordCount > wordLimit
@logThis(question, "validateWordLimit", "Word limit exceeded")
Expand Down Expand Up @@ -823,12 +824,12 @@ window.FormValidation =
qRef = question.attr("data-question_ref")
qTitle = $.trim(question.find("h2").first().text())

if typeof console != "undefined"
console.log "-----------------------------"
console.log("[STEP]: " + stepTitle)
console.log(" [QUESTION] " + qRef + ": "+ qTitle)
console.log(" [" + validator + "]: " + message)
console.log "-----------------------------"
# if typeof console != "undefined"
# console.log "-----------------------------"
# console.log("[STEP]: " + stepTitle)
# console.log(" [QUESTION] " + qRef + ": "+ qTitle)
# console.log(" [" + validator + "]: " + message)
# console.log "-----------------------------"

hookIndividualValidations: ->
self = @
Expand Down Expand Up @@ -984,6 +985,7 @@ $(document).on 'change', 'input[type=checkbox]', ->
window.FormValidation.validateMatrix(question)

$(document).on 'change', '[data-question-haltable] .show-question input.govuk-input', ->
console.log('change1')
questions = $(document).find('.question-block')
questions.removeClass('js-question-disabled')
questions.removeAttr('inert')
Expand Down

0 comments on commit 911b746

Please sign in to comment.