Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/08/2010, 18:28
laupatri1084
 
Fecha de Ingreso: octubre-2009
Mensajes: 68
Antigüedad: 15 años, 3 meses
Puntos: 1
validacion texto

hola amigos mi problema es sencillo ,pero no he logrado resolverlo la verdad no se mucho de javascrip estoy empezando estoy corrigiendo la validacion de varios formularios en mi sitio para el texto se utiliza la siguiente funcion pero esta acepta numeros y simbolos ,solo debe aceptar letras para campos como por ejemplo nombres apellidos etc
asi estaba valida solo la longuitud del campo y que no este vacio

function campo_texto_1(linea, long, texto, mensaje)
{


if(typeof(texto)== 'undefined'){texto = "";}

if (linea.value == "" || linea.value == texto || linea.value.length < long )
{
if(typeof(mensaje)!= 'undefined'){alert (mensaje); linea.focus(); linea.select();}
return false;
}
else return true;
}


asi la modifique y no sirve


function campo_texto_1(linea, long, texto, mensaje)
{
var letras=/^[A-Za-z]$/

if(typeof(texto)== 'undefined'){texto = "";}

if (linea.value == "" || linea.value == texto || linea.value.length < long ||!letras.test(linea.value) )
{
if(typeof(mensaje)!= 'undefined'){alert (mensaje); linea.focus(); linea.select();}
return false;
}
else return true;
}

Ayuda por fa