Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/11/2010, 12:23
almasysm
 
Fecha de Ingreso: octubre-2010
Mensajes: 5
Antigüedad: 13 años, 6 meses
Puntos: 0
Dos funciones on submit

Hola
He estado creando un formulario con dos validaciones, una de los campos obligatorios a rellenar y la otra una casilla de aceptación de las normas. Pero no consigo que funcionen las dos, me ignora una de ellas aunque si me lanza el mensaje de alerta (la de DoTheCheck).
Os agradecería una ayudita
Gracias
Os dejo el código




<script type="text/javascript">
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }

function DoTheCheck(x) {
var x=document.econieve.normas.checked
if(x == false)
{
document.econieve.normas.focus()
alert('DEBES ACEPTAR LAS NORMAS DEL CLUB')
return false
}
}


</script>
<style type="text/css">
body {
background-image: url(fondo-formulario3.jpg);
}
</style>
</head>

<body>


<form action="formulario.php" method="post" name="eco" id="eco" onsubmit="MM_validateForm('Nombre','','R','Apellid os','','R','DNI-NIF','','R','tele1','','R','sms','','R','Email','' ,'R','Direcci&oacute;n','','R','Poblaci&oacute;n', '','R','cp','','R','Alergias','','R','enf','','R') ;return document.MM_returnValue" >