horrifying JS fix for counting max chars