Any thoughts on how to add a script in Adobe Acrobat 2017 to a text box, which will perform and show a current word count from a required amount "Say 250 words", and if this is not achieved, then show a message box saying "Word count much exceed 250"
I have 4 text boxes on a form and need this to show in a field above each text box.
Thank you for any help provided
If you want the counter to update "live", as the user is typing, it's a bit of a complicated task.
I've written a tool that allows you to set it up easily, and it can be customized to show this error message you want.
You can find it here: Custom-made Adobe Scripts: Acrobat -- "Live" Characters and Words Counter
Hi Appreciate the response.
Is there a version I can try before I purchase?
I would like to see how this works with my form before purchasing.
Send me an email (try6767 at gmail.com) and we could discuss it further.
counting words in a text box is pretty easy.
var strText = this.getField("textfield").value;
var aWords = strText.split(/\s+/);
var nCount = aWords.length;
this code could go into a calculation script for a text box that displays a message, or with some modification it could be used in a Keystroke script on the field being counted, to return real time results.
You'll find scripts for this exact purpose( and much more ) on this subscription site:
Calculating field values and more (look at the article Counting Text items)
Hi and thank you for the link,
I will check out and revert back if I get my solution.
I am a novice though, so it may take some time and more questions being asked.
When I add the "word count" code it removes the multi-line formatting. Is there a way to do both?
On the text field that you want to test, add this code as a custom validation event to each of the fields you want to test. (you could use a document level script but that is not needed if you only have 4 fields to work with)
var aWord = event.value.split(/\s+/);
this.getField("Text5").value = aWord.length;
if ( aWord.length < 250)
app.alert ( "Word count must exceed 250");
This is a variation on the code above, the reason to place it in the validation event is that then it will only be fired when the user leaves that field and therefore should be the correct time to tell them that they have not entered the correct amount of words.
Hope this helps
I already have the code in place and it works, I just need to know how to keep the Multi-line function. When I implement the word count code it makes the text revert to a single line scroll.
The two things have nothing to do with each other.
Sorry perhaps I wasn't clear, when I used the code in my example in the locations I specified I didn't loose the multi line option, therefore I suggested you use that and see if it was some other code that was causing the problem because as stated above, the two are not related.