// COUNT TITLE
$(document).ready(function(){
    var totalChars      = 80; //Total characters allowed in textarea
    var countTextBox    = $('#count_titel') // Textarea input box
    var charsCountEl    = $('.countchars_titel'); // Remaining chars count will be displayed here
   
    charsCountEl.text(totalChars); //initial value of countchars element
    countTextBox.keyup(function() { //user releases a key on the keyboard
       
        var thisChars = this.value.replace(/{.*}/g, '').length; //get chars count in textarea

        var per = thisChars *100;
        var value= (per / totalChars); // total percent complete
   
        if(thisChars > totalChars) //if we have more chars than it should be
        {
            var CharsToDel = (thisChars-totalChars); // total extra chars to delete
            this.value = this.value.substring(0,this.value.length-CharsToDel); //remove excess chars from textarea
        }else{
            charsCountEl.text( totalChars - thisChars ); //count remaining chars
            $('#percent').text(value +'%');
        }
    });
});