function isvalidchar(achar,validstr)     
{
     return( validstr.toUpperCase().indexOf(achar.toString().toUpperCase(),0) >= 0 );
}


function isvalidstring(str,validstr)     //// determines if a string is valid ( contains only chars in validstr )
{
     for ( var i=0; i<str.length; i++ )
     {
          if ( !isvalidchar(str.charAt(i),validstr) )
          {
               return(false);
          }
     }

     return(true);
}

function validar(document) 
{
if ((document.nombre.value == "") || (document.nombre.value== null)) {
alert("Debés ingresar el nombre"); 
document.nombre.focus();
return false;
}
else 
  if ( !isvalidstring(document.nombre.value,"ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "0123456789 "  + "abcdefghijklmnñopqrstuvwxyzáéíóú ") )
  {
      document.nombre.select();
      alert("El Nombre  sólo debe contener letras o números (NO apóstrofes, comas o guiones).");
      document.nombre.focus();
      return(false);
}
else 
if ((document.apellido.value == "") || (document.apellido.value== null)) {
alert("Debés ingresar el apellido"); 
document.apellido.focus();
return false;
}
else 
  if ( !isvalidstring(document.apellido.value,"ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "0123456789 "  + "abcdefghijklmnñopqrstuvwxyzáéíóú ") )
  {
      document.apellido.select();
      alert("El apellido sólo debe contener letras o números (NO apóstrofes, comas o guiones).");
      document.apellido.focus();
      return(false);
}

else 
if ((document.dni.value == "") || (document.dni.value== null)) {
alert("Debés ingresar el número de documento"); 
document.dni.focus();
return false;
}
else 
  if ( !isvalidstring(document.dni.value,"0123456789") )
  {
      document.dni.select();
      alert("El dni debe ser un número sin puntos.");
      document.dni.focus();
      return(false);
}
else 
if ((document.mail.value == "") || (document.mail.value== null)) {
alert("Debés ingresar tu mail."); 
document.mail.focus();
return false;
}

else 
if ((document.prov.value == "") || (document.prov.value== null)) {
alert("Debés ingresar la provincia."); 
document.prov.focus();
return false;
}
else 
if ((document.cargo.value == "") || (document.cargo.value== null)) {
alert("Debés ingresar el cargo."); 
document.cargo.focus();
return false;
}
else 
if ((document.nivel.value == "") || (document.nivel.value== null)) {
alert("Debés ingresar el nivel."); 
document.nivel.focus();
return false;
}
else 
if ((document.area.value == "") || (document.area.value== null)) {
alert("Debés ingresar el área."); 
document.area.focus();
return false;
}
else 
return true;
}

