Ver Mensaje Individual
  #11 (permalink)  
Antiguo 23/02/2008, 16:51
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: Validar form clickando input image

Usando las funciones de macromedia sería así:
Código 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">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Documento sin t&iacute;tulo</title>
<
script type="text/JavaScript">
<!--
function 
MM_findObj(nd) { //v4.01
  
var p,i,x;  if(!dd=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    
d=parent.frames[n.substring(p+1)].documentn=n.substring(0,p);}
  if(!(
x=d[n])&&d.allx=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(
i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!
&& d.getElementByIdx=d.getElementById(n); return x;
}

function 
MM_validateForm() { //v4.0
  
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=MM_findObj(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+' 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<numerrors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (
test.charAt(0) == 'R'errors += '- '+nm+' is required.\n'; }
  } if (
errorsalert('The following error(s) occurred:\n'+errors);
  
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<form name="alojar" method="post" action="http://url/includes/upload_basic.php" style="margin:0px;" enctype="multipart/form-data" onsubmit="MM_validateForm('theme','','R','preview','','R','nombre','','R'); return document.MM_returnValue;">  

    <table width="770" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="400" height="20" align="left">Imagen preview: </td>
        <td width="30" align="left">&nbsp;</td>
        <td align="left">Nombre:</td>
        <td align="left">&nbsp;</td>
      </tr>
      <tr>
        <td height="20" align="left"><input name="preview" type="file" size="40" /></td>
        <td align="left">&nbsp;</td>
        <td align="left"><input name="nombre" type="text" size="25" /></td>
        <td align="left">&nbsp;</td>
      </tr>
      <tr>
        <td height="30" align="left" valign="bottom">Theme:</td>
        <td align="left">&nbsp;</td>
        <td align="left" valign="bottom">&nbsp;</td>
        <td align="left" valign="bottom">&nbsp;</td>
      </tr>
      <tr>
        <td align="left"><input name="theme" type="file" size="40" /></td>
        <td colspan="2" rowspan="2" align="left"><span style="text-align:center; margin:10px;">
          <input name="enviar" type="image" style="cursor:pointer"  src="http://url/media/images/formulario/upload.gif" border="0"/>
        </span></td>
        <td align="left" valign="bottom">&nbsp;</td>
      </tr>
      <tr>
        <td align="left">&nbsp;</td>
        <td align="left" valign="bottom">&nbsp;</td>
      </tr>
    </table>
  </form></body>
</html> 

Última edición por Panino5001; 23/02/2008 a las 17:13