256 Kilobytes

How to Add a Word Counter to MTurk Hits (as a Requester/Job Poster)

Articles in Content Writing and Blogging | By August R. Garcia

Published | Last Update

Make your tasks easier to complete and get results more quickly.

652 views, 1 RAM, and 0 comments

While the MTurk documentation provides instructions for input validation (such as preventing submissions if a particular word count is not met), there seems to be no documentation on how to actually ad a realtime word counter that writers/workers can use while writing answer texts. Fortunately, this is done easily with a few lines of JavaScript (which you can copy-paste without needing to understand).

When creating a hit, the source code will have a section along these lines:

<!-- Input from Worker -->
<div class="form-group">
 <textarea class="form-control" cols="250"
           id="WritingTexts" name="WritingTexts"
           required="" rows="6"></textarea>
<!-- End input from Worker -->

To add a word counter, add the following code:

<!-- Input from Worker -->

<div class="form-group">

          <!-- Add oninput="update_word_count();" to the textarea
                    To make the script check the word count any time the user
                    Types or changes anything in the textarea -->
          <textarea class="form-control" cols="250"
          id="WritingTexts" name="WritingTexts" required="" rows="6"

<!-- This is a non-editable input that will show the word count to the writer -->
<input class="form-control" id="WordCount" name="WordCount" placeholder="0" disabled /> <br/>

function update_word_count() {
 // Read in the text from the textarea so that the
 // script can determine the current word count
 // If the value of your textarea is not "WritingTexts"
 // then change the id on the following line as well
 var str = document.getElementById("WritingTexts").value;

 var stringArray = str.split(' ');
 var count = 0;
 for (var i = 0; i < stringArray.length; i++) {
   var word = stringArray[i];
   if (/[A-Za-z]/.test(word)) { count++ }

 // Update the word count input field 
 document.getElementById("WordCount").value = count;
<!-- End input from Worker -->

You can see a demo of how this functions below:

Making your tasks easier to complete for workers is generally a good idea, since it allows for faster results with fewer errors. Making tasks easier and quicker to complete can also reduce your costs substantially, depending on the number of tasks that need to be completed.

Users Who Have Downloaded More RAM:
Hash Brown (2 years ago)
🐏 ⨉ 1
Posted by August R. Garcia 2 years ago

Edit History

• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
• [2019-03-27 9:31 PDT] August R. Garcia (2 years ago)
🕓 Posted at 27 March, 2019 09:31 AM PDT

Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite Owner

August Garcia is some guy who used to sell Viagra on the Internet. He made this website to LARP as a sysadmin while posting about garbage like user-agent spoofing, spintax, the only good keyboard, virtual assitants from Pakistan, links with the rel="nofollow" attributeproxiessin, the developer console, literally every link building method, and other junk.

Available at arg@256kilobytes.com, via Twitter, or arg.256kilobytes.com. Open to business inquiries based on availability.

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account