Foros del Web » Programando para Internet » Javascript »

ayuda formulario

Estas en el tema de ayuda formulario en el foro de Javascript en Foros del Web. estoy haciendo un formulario q me valida campos y texto segun sea la necesidad. el problema es q cuando el textfield valida el campo me ...
  #1 (permalink)  
Antiguo 09/11/2010, 09:26
 
Fecha de Ingreso: noviembre-2007
Mensajes: 14
Antigüedad: 16 años, 5 meses
Puntos: 0
ayuda formulario

estoy haciendo un formulario q me valida campos y texto segun sea la necesidad. el problema es q cuando el textfield valida el campo me vota el alert q es caracter errado, pero luego me lo envia, y no entiendo pq, el codigo es el siguiente:
funciones:
function validaText(valor){
var reg=valor.search('[^a-zA-ZñÑ ]');

if(reg>=0)
return false;
else return true;
}



function validarNumerico(valor)
{
if(valor != "")
{
if (isNaN(valor)==true)
return false;
else return true;
}
return false;
}

function validaCorreo(valor)
{
var reg=/(^[a-zA-Z0-9._-]{1,30})@([a-zA-Z0-9.-]{1,30}$)/;
if(reg.test(valor)) return true;
else return false;
}


function validacampos()
{
// var id = $("#id").val();
// var contra = document.getElementById("clave").value;
//
//alert('validaText: '+validaText('idNomAdministrador')+'\n');
//alert('validarNumerico: '+validarNumerico('idNomAdministrador')+'\n');
if(($("#idNomAdministrador").val() == "" ) || (validaText('idNomAdministrador')) )
{
alert("Caracteres errados");
return false;
}
if(($("#idDirAdministrador").val() == "" ) )
{
alert("Ingrese una direccion");
return false;
}
else if(($("#idTeldministrador").val() == "" ) || (validarNumerico('idTelAdministrador')) )
{
alert("Caracteres errados");
return false;
}
else if(($("#idEmailAdministrador").val() == "" ) || (validaCorreo('idEmailAdministrador')) )
{
alert("caracteres errados");
return false;
}
else if(($("#idRazSocAdministrador").val() == "" ))
{
alert("Ingrese la razon social");
return false;
}
else if( $("#idNitAdministrador").val() == "" )
{
alert("Ingrese un Nit");
return false;
}
else if( $("#idWebAdministrador").val() == "" )
{
alert("Ingrese un Sitio Web");
return false;
}
}
asi lo llamo en el form
<form name="form1" method="post" action="" onSubmit="validacampos()" >

agradezco su colaboracion
  #2 (permalink)  
Antiguo 09/11/2010, 18:13
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: ayuda formulario

Debería ser:
Código Javascript:
Ver original
  1. return validacampos();
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.

Etiquetas: formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:55.