From a string I need to know how many characters there are without counting spaces or numbers and send it to print, as well as another function that tells me if there are numbers and how many of that same string, even without spaces, this is what I have done so far.
I already get how many characters but I don't want it to count the numbers, I want them separately:
function cadenaNumerosLetras(){
var frase = document.getElementById(‘cadena’).value;
var letterCount = frase.split(/\W/).join('').length;
var contadorLetras = letterCount.toString();
console.log(letterCount);
document.getElementById(‘resultado’).value = contadorLetras;
var numeros = "0123456789";
if(!isNaN(frase)){
for(i=0; i<frase.length;i++){
if(numeros.indexOf(frase.charAt(i),0)!=-1){
return 1;
document.getElementById('numeros').innerHTML= frase;
}
}
return 0;
}
}