function trim(str){return str.replace(/^\s+|\s+$/g,"");} // Removes leading and ending whitespaces
function ltrim(str){return str.replace(/^\s+/,"");} // Removes leading whitespaces
function rtrim(str){return str.replace(/\s+$/,"");} // Removes ending whitespaces
function countRestWord(tarea,max,divid){
    var inp = tarea.value.replace(/^\s+|\s+$/g,'');
    var l = parseInt(inp.length)
    if (l > max){inp = inp.substr(0,max); tarea.value = inp; }
    document.getElementById(divid).innerHTML = inp.length;
}
function restw(frm,max,dispentered){
    var inp = frm.value.replace(/^\s+|\s+$/g,'');
    var l = parseInt(inp.length)
      if (l > max){ inp = inp.substr(0,max);frm.value = inp; }
    document.getElementById(dispentered).innerHTML = inp.length;
}
// Function to remove HTML entities from String
function strip_tags(text){
    return text.replace(/<\/?[^>]+>/gi, '');
}
