Logo
This plugin integrates by default with Twitter bootstrap using badges to display the maximum length of the field where the user is inserting text. Uses the HTML5 attribute "maxlength" to work.
For more info please visit the plugin's Demo Pageor Github Repo.

Bootstrap Maxlength Examples


       <div class="card card-custom">
        <div class="card-header">
         <h3 class="card-title">
          Bootstrap Maxlength Examples
         </h3>
        </div>
        <!--begin::Form-->
        <form class="form">
         <div class="card-body">
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Default Usage</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <input type='text' class="form-control" id="kt_maxlength_1" maxlength="3"  placeholder="" type="text"/>
            <span class="form-text text-muted">The badge will show up by default when the remaining chars are 3 or less</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Threshold Demo</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <input type='text' class="form-control" id="kt_maxlength_2" maxlength="7"  placeholder="" type="text"/>
            <span class="form-text text-muted">Set threshold value to show there are 5 chars or less</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Always Show</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <input type='text' class="form-control" id="kt_maxlength_3" maxlength="6"  placeholder="" type="text"/>
            <span class="form-text text-muted">Show the counter on input focus</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Custom Text</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <input type='text' class="form-control" id="kt_maxlength_4" maxlength="8"  placeholder="" type="text"/>
            <span class="form-text text-muted">Display custom text on input focus</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Textarea Example</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <textarea class="form-control" id="kt_maxlength_5" maxlength="8"  placeholder="" rows="6"></textarea>
            <span class="form-text text-muted">Bootstrap maxlength supports textarea as well as inputs</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Positions</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <input type='text' class="form-control" id="kt_maxlength_6_1" maxlength="8"  placeholder="Top left" type="text"/>
            <div class="mt-3"></div>
            <input type='text' class="form-control" id="kt_maxlength_6_2" maxlength="8"  placeholder="Top right" type="text"/>
            <div class="mt-3"></div>
            <input type='text' class="form-control" id="kt_maxlength_6_3" maxlength="8"  placeholder="Bottom left" type="text"/>
            <div class="mt-3"></div>
            <input type='text' class="form-control" id="kt_maxlength_6_4" maxlength="8"  placeholder="Bottom right" type="text"/>
            <span class="form-text text-muted">The field counter can be positioned at the top, bottom, left or right.</span>
           </div>
          </div>
          <div class="form-group row">
           <label class="col-form-label text-right col-lg-3 col-sm-12">Modal Demos</label>
           <div class="col-lg-4 col-md-9 col-sm-12">
            <a href="" class="btn btn-light-primary font-weight-bold" data-toggle="modal" data-target="#kt_maxlength_modal">Launch maxlength inputs on modal</a>
           </div>
          </div>
         </div>
         <div class="card-footer">
          <div class="row">
           <div class="col-lg-9 ml-lg-auto">
            <button type="reset" class="btn btn-primary mr-2">Submit</button>
            <button type="reset" class="btn btn-secondary">Cancel</button>
           </div>
          </div>
         </div>
        </form>
        <!--end::Form-->
       </div>
      

      // Class definition

      var KTBootstrapMaxlength = function () {

       // Private functions
       var demos = function () {
        // minimum setup
        $('#kt_maxlength_1').maxlength({
         warningClass: "label label-warning label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline"
        });

        // threshold value
        $('#kt_maxlength_2').maxlength({
         threshold: 5,
         warningClass: "label label-warning label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline"
        });

        // always show
        $('#kt_maxlength_3').maxlength({
         alwaysShow: true,
         threshold: 5,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        // custom text
        $('#kt_maxlength_4').maxlength({
         threshold: 3,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline",
         separator: ' of ',
         preText: 'You have ',
         postText: ' chars remaining.',
         validate: true
        });

        // textarea example
        $('#kt_maxlength_5').maxlength({
         threshold: 5,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        // position examples
        $('#kt_maxlength_6_1').maxlength({
         alwaysShow: true,
         threshold: 5,
         placement: 'top-left',
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        $('#kt_maxlength_6_2').maxlength({
         alwaysShow: true,
         threshold: 5,
         placement: 'top-right',
         warningClass: "label label-success label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        $('#kt_maxlength_6_3').maxlength({
         alwaysShow: true,
         threshold: 5,
         placement: 'bottom-left',
         warningClass: "label label-warning label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        $('#kt_maxlength_6_4').maxlength({
         alwaysShow: true,
         threshold: 5,
         placement: 'bottom-right',
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline"
        });

        // Modal Examples

        // minimum setup
        $('#kt_maxlength_1_modal').maxlength({
         warningClass: "label label-warning label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline",
         appendToParent: true
        });

        // threshold value
        $('#kt_maxlength_2_modal').maxlength({
         threshold: 5,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline",
         appendToParent: true
        });

        // always show
        // textarea example
        $('#kt_maxlength_5_modal').maxlength({
         threshold: 5,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-primary label-rounded label-inline",
         appendToParent: true
        });

        // custom text
        $('#kt_maxlength_4_modal').maxlength({
         threshold: 3,
         warningClass: "label label-danger label-rounded label-inline",
         limitReachedClass: "label label-success label-rounded label-inline",
         appendToParent: true,
         separator: ' of ',
         preText: 'You have ',
         postText: ' chars remaining.',
         validate: true
        });
       }

       return {
        // public functions
        init: function() {
         demos();
        }
       };
      }();

      jQuery(document).ready(function() {
       KTBootstrapMaxlength.init();
      });

      
The badge will show up by default when the remaining chars are 3 or less
Set threshold value to show there are 5 chars or less
Show the counter on input focus
Display custom text on input focus
Bootstrap maxlength supports textarea as well as inputs
The field counter can be positioned at the top, bottom, left or right.

Notifications 24 New

Quick Actions finance & reports

User Profile 15 messages

Recent Notifications

Important Notice

Lorem Ipsum is simply dummy text of the printing and industry.

System Update

There are many variations of passages of Lorem Ipsum available.

Server Maintenance

Contrary to popular belief, Lorem Ipsum is not simply random text.

DB Migration

If you are going to use a passage of Lorem Ipsum, you need.

System Messages
09:30 AM

To start a blog, think of a topic about and first brainstorm ways to write details

2:45 PM

To start a blog, think of a topic about and first brainstorm ways to write details

3:12 PM

To start a blog, think of a topic about and first brainstorm ways to write details

7:05 PM

To start a blog, think of a topic about and first brainstorm ways to write details

Notifications
Pic
Marcus Smart UI/UX, Art Director
+65%
AH
Andreas Hawks Python Developer
+23%
SC
Sarah Connor HTML, CSS. jQuery
-34%
Pic
Amanda Harden UI/UX, Art Director
+72%
SR
Sean Robbins UI/UX, Art Director
+65%
JT
Jason Tatum ASP.NET Developer
+139%

Privacy Settings:

After you log in, you will be asked for additional information to confirm your identity.

Security Settings:

After you log in, you will be asked for additional information to confirm your identity. For extra security, this requires you to confirm your email. Learn more.

Select A Demo

Demo 1
Demo 2
Demo 3
Demo 4
Demo 5
Demo 6
Demo 7
Demo 8
Demo 9