--- title: Text Area Word Count type: plugins category: Validation cat: validation order: 130 meta_title: Text Area Word Count meta_description: Validates the length of a text area based on its word count tier: enterprise --- !!! note For information about modifying this plugin or creating your own custom plugins, see [Customize and Build Your Own Plugins](custom). For general plugin information, see [Plugins for projects](/guide/plugins) and [Plugin FAQ](faq). ## About This plugin validates whether users have exceeded a word count restriction. ![Screenshot of warning](/images/plugins/wordcount.png) ## Plugin As scripted, this plugin sets a restriction of 10 words. You can modify the word count as necessary. ```javascript /** * Validates the word count of the entered text to prevent submission if it exceeds a specified threshold */ let dismissed = false; LSI.on("beforeSaveAnnotation", (store, annotation) => { const textAreaResult = annotation.results.find( (r) => r.type === "textarea" && r.from_name.name === "textarea", ); if (textAreaResult) { words = textAreaResult.value.text[0]; word_count = words.split(" ").length; if (word_count > 10) { Htx.showModal( `Word count is ${word_count}. Please reduce to 10 or less.`, ); dismissed = true; return false; // Block submission } } return true; // Allow submission }); ``` **Related LSI instance methods:** * [on(eventName, handler)](custom#LSI-on-eventName-handler) **Related frontend events:** * [beforeSaveAnnotation](/guide/frontend_reference#beforeSaveAnnotation) ## Labeling config ```xml