Foros del Web » Programando para Internet » Javascript »

Problema javascript en firefox

Estas en el tema de Problema javascript en firefox en el foro de Javascript en Foros del Web. Hola , necesito que me ayuden. El siguiente código de un formulario me funciona perfectamente en internet explorer, pero no en firefox. Codigo html formulario: ...
  #1 (permalink)  
Antiguo 22/01/2010, 13:21
 
Fecha de Ingreso: julio-2009
Mensajes: 5
Antigüedad: 14 años, 9 meses
Puntos: 0
Exclamación Problema javascript en firefox

Hola , necesito que me ayuden. El siguiente código de un formulario me funciona perfectamente en internet explorer, pero no en firefox.

Codigo html formulario:
Código:
<form name="form_contacto" action="?m=contacto" method="post" onSubmit="return validar_contacto(this);">
<input type="hidden" name="codigo" value=<? echo "$codigo"; ?>>	
<input type="hidden" name="ip" value="<?php echo $_SERVER[REMOTE_ADDR] ?>">
<input type="hidden" name="correcto" value="si">
<p>	
<label>Tu Nombre y Apellido*</label>
<input name="nombre" type="text" size="30" maxlength="20" onkeyup="return validar_nombre(this);" />
<span style="float:right" id="error_nombre"><img id="img_checkform" src="images/incorrecto.png" /> 5 Carácteres mínimo.</span>
<span id="correcto_nombre" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span>
</p>

<p>
<label>Tu Email*</label>
<input name="email" type="text" size="30" maxlength="50" onkeyup="return validar_email(this);" />
<span style="float:right" id="error_email" ><img id="img_checkform" src="images/incorrecto.png" /> Ingrese un email válido.</span>
<span id="correcto_email" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span>
</p>

<p>
<label>Motivo del contacto*</label><span style="float:right" id="error_motivo" ><img id="img_checkform" src="images/incorrecto.png" /> Seleccione alguna opcion.</span>
<span id="correcto_motivo" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span><br />
<input type="radio" value="productos" name="motivo" onclick="Ocultar(otro); Mostrar(selecproducto); Ocultar(error_motivo); Mostrar(correcto_motivo);" />Consulta sobre productos.<br />
<input type="radio" value="duda" name="motivo" onclick="Ocultar(selecproducto); Ocultar(otro); Ocultar(error_motivo); Mostrar(correcto_motivo);" />Duda o Sugerencia.<br />
<input type="radio" value="otro" name="motivo" onclick="Ocultar(selecproducto); Mostrar(otro); Ocultar(error_motivo); Mostrar(correcto_motivo);" />Otro.<br />

</p>

<div id="selecproducto" style="display:none">
<p>
<label>Seleccione el Producto*</label>
<select onchange="Ocultar(error_selecproducto); Mostrar(correcto_selecproducto);" size="1" name="cualproducto">
<option selected="selected">Seleccione un producto*</option>
<?
while ($Cadaproducto = mysql_fetch_assoc($HacerConsultaProductos)) {
$idproducto = $Cadaproducto['ID'];
$nombreproducto = $Cadaproducto['nombre'];
$rutaproducto = $Cadaproducto['ruta'];


?>
<option value="<? echo "$idproducto"; ?>"><? echo "$nombreproducto"; ?></option>
<? } ?>
</select>
<span style="float:right" id="error_selecproducto" ><img id="img_checkform" src="images/incorrecto.png" /> Seleccione alguna opcion</span>
<span id="correcto_selecproducto" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span>
</p><br />
</div>


<div id="otro" style="display:none">
<p>
<label>Escriba su motivo*</label>
<input name="otromotivo" type="text" size="30" maxlength="50" onkeyup="return validar_otro(this);" />
<span style="float:right" id="error_otromotivo" ><img id="img_checkform" src="images/incorrecto.png" /> Escriba algún motivo</span>
<span id="correcto_otromotivo" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span>
</p>
</div>

<p>
<label>Tu Mensaje (dudas, mas datos de contacto, etc)*</label>
<span style="float:right" id="error_mensaje"><img id="img_checkform" src="images/incorrecto.png" /> 20 Carácteres mínimo y 500 máximo</span>
<span id="correcto_mensaje" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span><br />
<textarea name="mensaje" rows="5" cols="60" minlength="20" onkeyup="return validar_mensaje(this);" ></textarea>

<br /><br />
</p>

<p>
<label>Ingrese el C&oacute;digo *
<input name="codigo" type="button" value="<? echo "$codigo"; ?>" disabled></label>
<input name="codigo2" type="text" size="9" maxlength="5" onkeyup="return validar_codigo(this, <? echo "$codigo"; ?>);" />
<span style="float:right" id="error_codigo" ><img id="img_checkform" src="images/incorrecto.png" /> Ingrese el código.</span>
<span id="correcto_codigo" style="display:none; float:right;"><img id="img_checkform" src="images/correcto.png" /></span>
</p>

<p>
<input name="submit" type="submit" value="Enviar" class="button" />
<input name="reset" type="reset" class="button" />
</p>

<p>
* Campo Obligatorio.
</p>

</form>

Lo siguiente es el codigo javascript:
Código:
function validar_contacto(formulario) {
if (Se_Muestra(error_nombre) == true || Se_Muestra(error_email) == true || Se_Muestra(error_mensaje) == true || Se_Muestra(error_codigo) == true || Se_Muestra(error_motivo) == true) {
alert("Todos los campos deben tener un Ticket verde a su derecha.");
return false;
} else
if (Se_Muestra(seleccuadro) == true && Se_Muestra(error_seleccuadro) == true) {
alert("Todos los campos deben tener un Ticket verde a su derecha.");
return false;
} else
if (Se_Muestra(otro) == true && Se_Muestra(error_otromotivo) == true) {
alert("Todos los campos deben tener un Ticket verde a su derecha.");
return false;
} else {
return true;
};
};


function validar_nombre(nombre) {
if (nombre.value.length < 5) {
Ocultar(correcto_nombre);
Mostrar(error_nombre);
//alert('Complete el campo Nombre. 10 Carácteres mínimo.');
nombre.focus();
} else {
Ocultar(error_nombre);
Mostrar(correcto_nombre);
};
};


function validar_email(email) {
if (email.value.length < 5 || email.value.indexOf ('@', 0) == -1 || email.value.indexOf ('.', 0) == -1) {
Ocultar(correcto_email);
Mostrar(error_email);
email.focus();
} else {
Ocultar(error_email);
Mostrar(correcto_email);
};
};

function validar_otro(otro) {
if (otro.value.length < 4) {
Ocultar(correcto_otromotivo);
Mostrar(error_otromotivo);
otro.focus();
} else {
Ocultar(error_otromotivo);
Mostrar(correcto_otromotivo);
};
};

function validar_mensaje(mensaje) {
var mlength=mensaje.getAttribute? parseInt(mensaje.getAttribute("maxlength")) : ""
var minlength=mensaje.getAttribute? parseInt(mensaje.getAttribute("minlength")) : ""
if (mensaje.getAttribute && mensaje.value.length>mlength)
mensaje.value=mensaje.value.substring(0,mlength)

if (mensaje.value.length < minlength || mensaje.value.length > 500) {
Ocultar(correcto_mensaje);
Mostrar(error_mensaje);
mensaje.focus();
} else {
Ocultar(error_mensaje);
Mostrar(correcto_mensaje);
};
};


function validar_codigo(codigoingresado, codigo) {
if (codigoingresado.value < 5 || !(codigo == codigoingresado.value)) {
Ocultar(correcto_codigo);
Mostrar(error_codigo);
codigo2.focus();
} else {
Ocultar(error_codigo);
Mostrar(correcto_codigo);
};
};


function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function Alternar(Seccion){ 
if (Seccion.style.display=="none"){
Seccion.style.display="";
} else {
Seccion.style.display="none";
} 
}

function Mostrar(Seccion){ 
Seccion.style.display="";
}

function Ocultar(Seccion){ 
Seccion.style.display="none";
}

function Se_Muestra(Seccion) {
if (Seccion.style.display == "") {
return true;
} else {
return false;
};
};

Porfavor ayudenme y gracias de antemano.

Última edición por mihd; 22/01/2010 a las 16:25
  #2 (permalink)  
Antiguo 22/01/2010, 16:22
Avatar de zerokilled
Javascripter
 
Fecha de Ingreso: abril-2009
Ubicación: Isla del Encanto, La Borinqueña [+>==]
Mensajes: 8.050
Antigüedad: 15 años
Puntos: 1485
Respuesta: Problema javascript en firefox

calma piojo que el peine llega. primero, tienes codigo php. no todos sabemos php, pero mas importante aun es que no sabemos que genera ese codigo. deberias mostrar el codigo generado. segundo, no has explicado cual es el error que te aparece o cual es el resultado que esperabas. de todos modos, probe a cambiar toda la parte php por valores estaticos y en firefox me funciona bien. seria recomendable que nos indicaras una URL donde podamos hacer la prueba ya que tienes codigo php.
__________________
la maldad es una virtud humana,
y la espiritualidad es la lucha del hombre contra su maldad.
  #3 (permalink)  
Antiguo 22/01/2010, 16:56
 
Fecha de Ingreso: julio-2009
Mensajes: 5
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Problema javascript en firefox

gracias x responder. Ya solucione el problema. Me ayudó este post: http://www.forosdelweb.com/f13/not-defined-firefox-540554/


Salu2 y gracias

Etiquetas: firefox
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 16:36.