Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

progress bar with textarea issue

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
ASKER CERTIFIED SOLUTION
Avatar of SANDY_SK
SANDY_SK
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial