Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more jQuery: showing how many characters are left in post

  • Loading branch information...
commit 6d280af611174e8c6de9371a90aec3e390244f2d 1 parent 3a1051b
@garu authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 tweetylicious.pl
View
18 tweetylicious.pl
@@ -465,5 +465,23 @@ package main;
// creating our buttons
$(".options").find("a").button();
$("#submit").button();
+
+ // showing how many characters are left
+ $("#charsleft").text("140 characters left");
+ $("#message").keyup(function() {
+ var left = 140 - $("#message").val().length;
+ if (left < 0 ) {
+ $("#charsleft").removeClass("orange").addClass("red");
+ $("#submit").button("option", "disabled", true);
+ } else {
+ $("#submit").button("option", "disabled", false);
+ if (left < 40) {
+ $("#charsleft").removeClass("red").addClass("orange");
+ } else {
+ $("#charsleft").removeClass("red").removeClass("orange");
+ }
+ }
+ $("#charsleft").text( left + ' characters left' );
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.