Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problema con Script

  1. #1

    Problema con Script

    Buongiorno a tutti.

    Premetto che sono quasi un neofita e che magari la domanda potrà sembrarVi stupida, nel caso chiedo scusa in anticipo.

    Con Dreamweaver ho creato una tabella form, che vorrei inserire in un sito al quale sto lavorando. Per il controllo del form ho utilizzato Yaromat perchè mi sembrava più completo rispetto al controllo base di Dreamweaver.

    Se ne visualizzo l'anteprima nel browser tutto bene, funziona come dovrebbe.

    Ma appena copio ed incollo il medesimo codice nella pagina del sito Web non mi funziona. Mi convalida il form senza nessun controllo..
    Qualcuno ha idee a riguardo?

    Vi posto il codice della pagina:
    codice:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Documento senza titolo</title>
    <script type="text/javascript">
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d&#91;n&#93;)&&d.all) x=d.all&#91;n&#93;; for (i=0;!x&&i<d.forms.length;i++) x=d.forms&#91;i&#93;&#91;n&#93;;
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers&#91;i&#93;.document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function YY_checkform() { //v4.66
    //copyright (c)1998,2002 Yaromat.com
      var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
      for (var i=1; i<args.length;i=i+4){
        if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
        var myObj = MM_findObj(args&#91;i&#93;.replace(/\[\d+\]/ig,""));
        myV=myObj.value;
        if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
          if (myReq&&myObj.value.length==0){addErr=true}
          if ((myV.length>0)&&(args[i+2]==1)){ //fromto
            var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa&#91;0&#93;/1||myV > myMa&#91;1&#93;/1){addErr=true}
          } else if ((myV.length>0)&&(args[i+2]==2)){
              var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
          } else if ((myV.length>0)&&(args[i+2]==3)){ // date
            var myMa=args[i+1].split("#"); var myAt=myV.match(myMa&#91;0&#93;);
            if(myAt){
              var myD=(myAt[myMa&#91;1&#93;])?myAt[myMa&#91;1&#93;]:1; var myM=myAt[myMa&#91;2&#93;]-1; var myY=myAt[myMa&#91;3&#93;];
              var myDate=new Date(myY,myM,myD);
              if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
            }else{addErr=true}
          } else if ((myV.length>0)&&(args[i+2]==4)){ // time
            var myMa=args[i+1].split("#"); var myAt=myV.match(myMa&#91;0&#93;);if(!myAt){addErr=true}
          } else if (myV.length>0&&args[i+2]==5){ // check this 2
                var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
                if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
                if(!myObj1.checked){addErr=true}
          } else if (myV.length>0&&args[i+2]==6){ // the same
                var myObj1 = MM_findObj(args[i+1]);
                if(myV!=myObj1.value){addErr=true}
          }
        } else
        if (!myObj.type&&myObj.length>0&&myObj&#91;0&#93;.type=='radio'){
              var myTest = args&#91;i&#93;.match(/(.*)\[(\d+)\].*/i);
              var myObj1=(myObj.length>1)?myObj[myTest&#91;2&#93;]:myObj;
          if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
          if (args[i+2]==2){
            var myDot=false;
            for(var j=0;j<myObj.length;j++){myDot=myDot||myObj&#91;j&#93;.checked}
            if(!myDot){myErr+='* ' +args[i+3]+'\n'}
          }
        } else if (myObj.type=='checkbox'){
          if(args[i+2]==1&&myObj.checked==false){addErr=true}
          if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
        } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
          if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
        }else if (myObj.type=='textarea'){
          if(myV.length<args[i+1]){addErr=true}
        }
        if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
      }
      if (myErr!=''){alert('Le seguenti informazioni richieste sono incomplete o contengono errori:\t\t\t\t\t\n\n'+myErr)}
      document.MM_returnValue = (myErr=='');
    }
    </script>
    </head>
    
    <body>
    <form action="" method="post" name="form1" id="form1" onsubmit="YY_checkform('form1','Nome','#q','0','Il campo di testo \'Nome\' è obbligatorio.','Cognome','#q','0','Il campo di testo \'Cognome\' è obbligatorio.','e-mail','#S','2','Il campo di testo \'e-mail\' è obbligatorio e bisogna fornire un\'indirizzo mail valido.','Telefono','0_9','1','Il campo di testo \'Telefono\' non è valido','Fax','0_9','1','Il campo di testo \'Fax\' non è valido.','Gradirei Ricevere','#q','1','Selezionare Informazioni o Preventivo.');return document.MM_returnValue">
      <table width="409" border="1">
        <tr>
          <td width="105">Nome</td>
          <td width="288"><label>
            <input value="" type="text" name="Nome" id="Nome" />
          </label></td>
        </tr>
        <tr>
          <td>Cognome</td>
          <td><label>
            <input value="" type="text" name="Cognome" id="Cognome" />
          </label></td>
        </tr>
        <tr>
          <td>Azienda</td>
          <td><label>
            <input value="" type="text" name="Azienda" id="Azienda" />
          </label></td>
        </tr>
        <tr>
          <td>e-mail</td>
          <td><label>
            <input value="" type="text" name="e-mail" id="e-mail" />
          </label></td>
        </tr>
        <tr>
          <td>Indirizzo</td>
          <td><label>
            <input value="" type="text" name="Indirizzo" id="Indirizzo" />
          </label></td>
        </tr>
        <tr>
          <td>Città</td>
          <td><label>
            <input value="" type="text" name="Città" id="Città" />
          </label></td>
        </tr>
        <tr>
          <td>Telefono</td>
          <td><label>
            <input value="" type="text" name="Telefono" id="Telefono" />
          </label></td>
        </tr>
        <tr>
          <td>Fax</td>
          <td><label>
            <input value="" type="text" name="Fax" id="Fax" />
          </label></td>
        </tr>
        <tr>
          <td>Gradirei ricevere</td>
          <td><label>
            <select name="Gradirei Ricevere" id="Gradirei Ricevere">
              <option value="Seleziona" selected="selected">Seleziona</option>
              <option value="Preventivo">Preventivo</option>
              <option value="Informazioni">Informazioni</option>
            </select>
          </label></td>
        </tr>
        <tr>
          <td>Testo o commenti</td>
          <td><label>
            <textarea name="Commenti" id="Commenti" cols="45" rows="5"></textarea>
          </label></td>
        </tr>
        <tr>
          <td><input type="reset" name="Reset" id="Reset" value="Reset" /></td>
          <td><input type="submit" name="Invia" id="Invia" value="Invia" /></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    Grazie per l'attenzione, a presto.

    Andrea

  2. #2
    Risolto grazie e scusate il disturbo.

    Andrea

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.