Ver Mensaje Individual
  #6 (permalink)  
Antiguo 27/11/2008, 13:26
Avatar de msmtotti
msmtotti
 
Fecha de Ingreso: noviembre-2008
Mensajes: 47
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: novatillo, porque no chuta esto?

Mejor usa "getElementById" por k es mas facil traer el valor del textbox;
ya que si usas "getElementsByName" te trae un arreglo, y mas dificil sacar el valor del textbox
Espero k te sirve

<script LANGUAGE="JavaScript">
function CampoObligatorio(campo)
{
if(document.getElementById(campo) != null){
var s = document.getElementById(campo);
alert(s.value)
if (s.length == 0 || s.value=='')
{
alert("Este campo no puede estar vacio");
return false;
}
else {
alert("Trae Algo")
return true;
}
}
}
</script>

<input type="text" maxlength="20" name="tx_marca" id="nombre_marca">
<input type="submit" value="Siguiente" onclick="return CampoObligatorio('nombre_marca');"/>