Q:

Limit character input in the textarea including count using jquery

0

Limit character input in the textarea including count  using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<!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);
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now