HTML element to use for character count
Optional
config: CharacterCountConfig = {}Character count config
Protected
_$rootPrivate
$screenPrivate
$textareaPrivate
$visiblePrivate
configPrivate
i18nPrivate
lastPrivate
lastPrivate
maxPrivate
valueStatic
Constant
defaultsCharacter count default config
Static
elementStatic
moduleName for the component used when initialising using data-module attributes.
Static
Constant
schemaCharacter count config schema
Protected
$rootProtected
Returns the root element of the component
Private
bindPrivate
countPrivate
formatPrivate
getPrivate
handlePrivate
handlePrivate
Handle focus event
Speech recognition software such as Dragon NaturallySpeaking will modify
the fields by directly changing its value
. These changes don't trigger
events in JavaScript, so we need to poll to handle when and if they occur.
Once the keyup event hasn't been detected for at least 1000 ms (1s), check if the textarea value has changed and update the count message if it has.
This is so that the update triggered by the manual comparison doesn't conflict with debounced KeyboardEvent updates.
Private
handlePrivate
isPrivate
Check if count is over threshold
Checks whether the value is over the configured threshold for the input. If there is no configured threshold, it is set to 0 and this function will always return true.
true if the current count is over the config.threshold (or no threshold is set)
Private
updatePrivate
updatePrivate
updatePrivate
updateStatic
check
Character count component
Tracks the number of characters or words in the
.govuk-js-character-count
<textarea>
inside the element. Displays a message with the remaining number of characters/words available, or the number of characters/words in excess.You can configure the message to only appear after a certain percentage of the available characters/words has been entered.