Solved

progress bar with textarea issue

Posted on 2012-03-16
1
301 Views
Last Modified: 2012-03-16
i have successfully implemented the code for showing a progress bar to the textarea while typing, but it has one issue,

currently it works as whenever it reaches the end of the contents, it changes its color of progress bar...

currently all is working fine, my concern is if the remaining characters are left as less than 20, it should change another color as a warning sign to user

here is my code:

if some class needs to prepared to handle, plz guide thanks

var main = text_area_box.length * 100;
			var value= (main / max_numb_of_words);
			var count = max_numb_of_words - text_area_box.length;
			if(text_area_box.length <= max_numb_of_words)
			{
					$("#pbar").css("background","green");
				$('#count').html(count);
				$('#pbar').animate({"width": value+'%'}, 1);
			}
			else
			{
					$("#pbar").css("background","red");
				$("#textid").val(text_area_box.substr(0,max_numb_of_words));
			}

Open in new window



now here i also want to add a elseif block that if the textarea length left is low than 25, change color to darkred, so user should know that i have only few characters left

any guidance
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
SANDY_SK earned 500 total points
ID: 37729156
change your if loop to

if(text_area_box.length <= max_numb_of_words)
{
        if(count <= 25){
	        $("#pbar").css("background","red");
        } else {
	        $("#pbar").css("background","green");
        }
	$('#count').html(count);
	$('#pbar').animate({"width": value+'%'}, 1);
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question