Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/04/2010, 03:35
litto_007
 
Fecha de Ingreso: abril-2010
Mensajes: 2
Antigüedad: 14 años, 1 mes
Puntos: 0
problemas con javascript

Saludos a todos, la verdad no se que paso, estoy reciclando codigo de dos ejemplos que realice con anterioridad, y en los originales cumple su funcion javascript pero el el nuevo producto no, este es el codigo que tengo y por favor quisiera saber por que no me corre... gracias

Por si acaso estoy utilizando el servidor local XXAMP Y PHP 5 , CON PROGRAMACION ORIENTA OBJETOS EN PHP




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<script language="javascript">

//-------------------------------------------- VALIDACION DE CAMPOS
//valida campos vacios y q no tenga solo espacios
function vacio(q)
{
for ( i = 0; i < q.length; i++ )
{
if ( q.charAt(i) != " " )
{
return true
}
}
return false
}

//valida q solo sean letras
function validar(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron =/[A-Za-zñÑ\s]/;
te = String.fromCharCode(tecla);
alert("Ingrese su título obtenido ");
return patron.test(te);
}


//validar q sean solo numeros
function validarNum(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron = /[.,1234567890]/;
alert("Ingrese su título obtenido ");

te = String.fromCharCode(tecla);
return patron.test(te);
}

//valida el email
function mail(cadena) {
var a = cadena.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
if (a.length == 0 )
return true;
if (filter.test(a))
return true;
else
cadena.focus();
return false;
}

//valida todos los campos
function valida()
{
//verificamos campos vacios
if( vacio(document.formalmacen.cicliente.value) == false )
{
alert("Ingrese su carnet de identidad ");
document.formalmacen.cicliente.focus();
return false;
}

if( vacio(document.formalmacen.nomb_cliente.value) == false )
{
alert("Ingrese su nombre.");
document.formalmacen.nomb_cliente.focus();
return false;
}
if( vacio(document.formalmacen.ap1_cliente.value) == false )
{
alert("Ingrese su apellido paterno.");
document.formalmacen.ap1_cliente.focus();
return false;
}
if( vacio(document.formalmacen.dir_cliente.value) == false )
{
alert("Ingrese su direccion.");
document.formalmacen.dir_cliente.focus();
return false;
}
if( vacio(document.formalmacen.telf_cliente.value) == false )
{
alert("Ingrese su telefono.");
document.formalmacen.telf_cliente.focus();
return false;
}

return true;

}

</script>
</style>
<div id="formulario">
<div class="Estilo4 Estilo2 Titulo" id="titulo"><strong><span class="Estilo5">[titulo]</span></strong></div>
<form name="formalmacen" action="cliente.php?action=[accionFormulario]" enctype="multipart/form-data" method="post" onsubmit="javascript:return valida();"id="form1">



<table>
<tr><td class="Estilo5"><label class="labelform"><strong>Carnet identidad Cliente: </strong></label></td>
<td class="Estilo5"><input name="cicliente" type="text" size="8" maxlength="8" value="[ci]"onKeyPress="return validarNum(event)"/></td></tr>
<tr><td class="Estilo5"><label class="labelform"><strong>Nombre de Cliente: </strong></label></td>
<td class="Estilo5"><input name="nomb_cliente" type="text" onKeyPress="return validar(event)"onkeyup="this.value=this.value.toUp perCase()" value= "[nomb]"/></td></tr>
<tr><td class="Estilo5"><label class="labelform"><strong>Apellido Paterno: </strong></label></td>
<td class="Estilo5"><input name="ape1_cliente" type="text" onKeyPress="return validar(event)" onkeyup="this.value=this.value.toUpperCase()" value="[ape1]"/></td></tr>
<tr><td class="Estilo5"><label class="labelform"><strong>Apellido Materno: </strong></label></td>
<td class="Estilo5"><input name="ape2_cliente" type="text" onKeyPress="return validar(event)" onkeyup="this.value=this.value.toUpperCase()" value="[ape2]"/></td></tr>
<tr><td class="Estilo5"><label class="labelform"><strong>Direccion : </strong></label></td>
<td class="Estilo5"><input name="dir_cliente" type="text" onKeyPress="return validar(event)" onkeyup="this.value=this.value.toUpperCase()"value ="[dir]"/></td></tr>
<tr><td class="Estilo5"><label class="labelform"><strong>Telefono : </strong></label></td>
<td class="Estilo5"><input name="telf_cliente" type="text" onKeyPress="return validarNum(event)" value="[telf]"/></td></tr>
<TR><td class="Estilo5"><label class="labelform">Convenio:</td> <td></label>[conv]</label></td></tr>


</table>
<div class="botones">
<input type="submit" value="Guardar"/>
<input type="reset" value="Limpiar"/>
<input type="Button" value="Cancelar" onclick="closeajax('formulario'); return false;"/>
</div>
</form>
</div>

Última edición por litto_007; 14/04/2010 a las 03:40 Razón: me equivoque en la especificacion