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)); }
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