2
I have the script below which I am not sure how to prevent an entry whose any part of the name is only numeric. Example Fulano de Tal 123
return me valid.
function formatar() {
var nome = document.getElementById("nome").value;
var partes = nome.split(' ');
var IsNumericString = partes.filter(function(i){
return isNaN(i);
}).length > 0;
if (IsNumericString == 0 ) {
alert("Digite seu nome corretamente");
}else{
alert("Nome OK");
}
}
document.querySelector("button").addEventListener('click', formatar);
<input id="nome" type="text" value="Fulano de Tal" />
<button>Formatar</button>
It was really hard to choose which answer I should accept, but I’m a Sergio fan and that says it all :)
– user60252
@Leocaracciolo hahahaha, we are fans =)
– Mathiasfc