Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $(function () {
  2.  
  3. var text = $('#textarea');
  4.  
  5. text.on('input', function (event) {
  6. if (text.val().length <= 100) {
  7. $('p').text(text.val().length);
  8. if(text.val().length > 0 && text.val().length < 34){
  9. $('p').css('color', 'green');
  10. } else if (text.val().length > 33 && text.val().length < 67){
  11. $('p').css('color', 'orange');
  12. }else if (text.val().length > 66 && text.val().length < 101){
  13. $('p').css('color', 'red');
  14. }
  15. } else {
  16. text.on('keypress', function(event){
  17. event.preventDefault();
  18. });
  19. }
  20. });
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement