Limit character input in the textarea including count using jquery
<!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <meta charset="utf-8"> <title>Limit character input in the textarea including count</title> <style type="text/css"> textarea { display:block; margin:1em 0; } </style> </head> <body> <form> <label>Maximum 15 characters</label> <textarea id="textarea" maxlength="15"></textarea> <span id="rchars">15</span> Character(s) Remaining </form> </body>
</html>
JavaScript Code :
var maxLength = 15; $('textarea').keyup(function() { var textlen = maxLength - $(this).val().length; $('#rchars').text(textlen); });
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
JavaScript Code :