Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/09/2012, 08:20
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 17 años, 6 meses
Puntos: 28
Envio de Email form (campos vacios)

Saludos,
Estoy haciendo un formulario y bueno ya lo que queria funciona... lo que no me hace es que cuando el formulariop esta totalmente vacio no me da ninguna advertencia, de igual manera envia el formulaio vacio....

esto es lo q estoy usando para validar campos..
Código PHP:
<script type="text/javascript">
var 
numero 0;

// Funciones comunes
c= function (tag) { // Crea un elemento
   
return document.createElement(tag);
}
= function (id) { // Retorna un elemento en base al id
   
return document.getElementById(id);
}
= function (evt) { // Retorna el evento
   
return (!evt) ? event evt;
}
= function (evt) { // Retorna el objeto que genera el evento
   
return evt.srcElement ?  evt.srcElement evt.target;
}

addField = function () {
   
container d('files');
   
   
span c('SPAN');
   
span.className 'file';
   
span.id 'file' + (++numero);

   
field c('INPUT');   
   
field.name 'archivos[]';
   
field.type 'file';
   
   
c('A');
   
a.name span.id;
   
a.href '#';
   
a.onclick removeField;
   
a.innerHTML 'Quitar';

   
span.appendChild(field);
   
span.appendChild(a);
   
container.appendChild(span);
}
removeField = function (evt) {
   
lnk f(e(evt));
   
span d(lnk.name);
   
span.parentNode.removeChild(span);
}
function 
MM_validateForm() { //v4.0
  
if (document.getElementById){
    var 
i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (
i=0i<(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<|| p==(val.length-1)) errors+='- '+nm+' Debe contener al menos una dirección de Email.\n';
        } else if (
test!='R') { num parseFloat(val);
          if (
isNaN(val)) errors+='- '+nm+' Debe poseer un número.\n';
          if (
test.indexOf('inRange') != -1) { p=test.indexOf(':');
            
min=test.substring(8,p); max=test.substring(p+1);
            if (
num<min || max<numerrors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (
test.charAt(0) == 'R'errors += '- '+nm+' Campo Obligatorio.\n'; }
    } if (
errorsalert('Ha ocurrido lo siguiente:\n'+errors);
    
document.MM_returnValue = (errors == '');
} }
</script> 
pero porque al darle enviar con todos los campos vacios sigue enviando>??? que debo hacer???

Gracias de antemano
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...