Código HTML:
Ver original function validar() {
var elem = document.getElementById("prueba");
if (elem.value === "") {
elem.value = 'Por favor coloque el nombre';
elem.focus();
return false;
}
}
div{border:1px solid #000;padding:10px;font-size:10px;width:190px;height:40px;}
input{font-size:10px;width:150px;}
<form id="form1" name="form1" action="" method="post"> <input type="text" name="prueba" id="prueba" onfocusout="validar();" />