function contaCaracteres(boxcontado, contarcorpo, valormax) {
    
  var field = document.getElementById(boxcontado);
  if (field && field.value.length >= valormax) {
    field.value = field.value.substring(0, valormax);
  }
  var txtField = document.getElementById(contarcorpo);
  if (txtField) {  
    txtField.innerHTML = field.value.length;
  }
}