-2

So I have this textarea where their is a character limit. How to do it? I don't want the "character remaining type" like: "250 characters remaining". I want this type: "250/250" until it will go "0/250". How to do this?

HTML:

<textarea maxlength=250>Text Here</textarea>
<span id="charCount">250/250</span>
Rak
  • 139
  • 5
  • 20
  • Have you tried anything at all? Are you stuck on any particular implementation detail? – Phil Sep 28 '17 at 04:58
  • – Rehan Shikkalgar Sep 28 '17 at 05:11

1 Answers1

-3
    //try this   
   <textarea maxlength=250 id="text">Text Here</textarea>
     <span id="charCount">250/250</span>

   <script type="text/javascript" >
      $('#text').keypress(function() {
         var $self = $(this);
         var max = parseInt($(this).attr("maxlength"));

         if ($self.text().length > max) {
           return false;
         }

         $("#charCount").html((max - $self.text().length) + "/" + max);
      });
   </script>
Yeshan Jay
  • 1,403
  • 1
  • 9
  • 18
Dee_wab
  • 1,171
  • 1
  • 10
  • 23