CodeSOD: Characters Remaining

This post was originally published on this site

The Daily WTF

Tina works for a major European government. During the height pandemic, her team needed to roll out many new sites to support remote, self-service interactions with government agencies.

On one of these sites, they needed to create a contact form. The contact form was one of those that applied a character limit to the message. This character limit meant that the code needed to check the length of the input string, and then compare that against some max characters, and then output the “characters remaining” in an output field.

function textCounter(theField,theCharCounter,maxChars) { var strTemp = “”; for (var i = 0; i < theField.value.length; i++) { var strChar = theField.value.substring(i, i +

To read the full article click on the 'post' link at the top.