JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="row">
<h1 class="page-header">maxlengthVisualFeedback <small>Demo</small></h1>
<!-- Formular -->
<form name="Address" method="post" enctype="" action="" >
<div class="form-group">
<label for="Company">Company</label>
<input type="text"
class="form-control maxlengthVisualFeedback"
placeholder="Company"
maxlength="10"
autofocus="1"
autocomplete="off"
>
<sub>Please enter Company Name.</sub><br>
</div>
</form>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/gueff/jquery-maxlengthVisualFeedback@2.2/maxlengthVisualFeedback.js"></script>
<p>
Plase note:<br>
- The usage of Bootstrap CSS is <i>optional</i> and <i>not necessary</i>. It just looks way nicer ;-).
</p>
<p>
You might want to see the Blog Post to this Demo:<br>
- <a href="https://blog.ueffing.net/post/2018/02/17/jquery-maxlength-visual-feedback/">
https://blog.ueffing.net/post/2018/02/17/jquery-maxlength-visual-feedback/
</a>
<br><br>
Date: 2018-02-17
</p>
CSS
/* bootstrap
*/
@import "//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" screen, projection;
/* visualizeConsumption
*/
@import "//cdn.jsdelivr.net/gh/gueff/jquery-maxlengthVisualFeedback@2.2/maxlengthVisualFeedback.css" screen, projection;
/* ordinary css
*/
body{
padding: 20px;
}
JavaScript
// start Listener; activating jquery-charsConsumedVisualizer
$(".maxlengthVisualFeedback").on('click keyup keypress', function() {
maxlengthVisualFeedback($(this));
});