JQuery keyup keydown example



 jQuery("#content").keydown(function(event) {
 var text = jQuery('#content').val();
 var count = 15000 - text.length;
 if ((text.length) < 15000) {
 if (count >= 0)
 $('#count').html(count);
 } else {
 if (event.keyCode == '8') { //backspace
 text = text.substring(0, 15001);
 } else {
 text = text.substring(0, 14999);
 }
 jQuery('#content').val(text);
 }
 });

 jQuery("#content").keyup(function() {
 var text = jQuery('#content').val();
 var count = 15000 - text.length;
 if (text.length <= 15000) {
 if (count >= 0)
 $('#count').html(count);
 }
 });

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s