Visualizzazione dei risultati da 1 a 8 su 8

Discussione: Errore validatore

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,786

    Errore validatore

    salve,

    ho un form con questo codice:

    codice:
    <form action="#" method="post" name="informazioni" id="info">
    l'errore sta nel name="informazioni" come posso fare ?

    questo è quello che restituisce il validatore:

    Line 24, column 40: there is no attribute "name"

    <form action="#" method="post" name="informazioni" id="info">

    You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

    This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

    How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.
    grazie !
    [Scambio Links a Tema] Contattatemi in Privato x + Info.

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Evidentemente stai validando con DTD XHTML Strict.

    Il name non e` piu` valido per molti tag. Ne sono esclusi i tag all'interno dei form.

    Semplicemente togli l'attributo name.

    Se lo usi in un JS, devi sostituirlo con l'id (e sintassi getElementById() ).
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,786
    Originariamente inviato da Mich_
    Evidentemente stai validando con DTD XHTML Strict.

    Il name non e` piu` valido per molti tag. Ne sono esclusi i tag all'interno dei form.

    Semplicemente togli l'attributo name.

    Se lo usi in un JS, devi sostituirlo con l'id (e sintassi getElementById() ).
    allora, io lo uso in un js.

    lo recupero così:
    codice:
    var cognome = document.informazioni.cognome.value;
    & a volte mi serve nel js fare così:
    codice:
    document.informazioni.cognome.focus();
    quindi cosa devo fare oltre a togliere l'attributo name & sostituirlo con id ?

    grazie !
    [Scambio Links a Tema] Contattatemi in Privato x + Info.

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    id lo hai gia` messo nel form, non puoi metterne due.

    Il JS:
    document.NOMEFORM.NOEMCAMPO...
    diventa:
    document.getElementById('ID_FORM').NOMECAMPO...
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  5. #5
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,786
    grazie !
    [Scambio Links a Tema] Contattatemi in Privato x + Info.

  6. #6
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    1,786
    perchè non funziona ?

    invia il modulo anche se il campo è vuoto,
    non restituisce nessun errore

    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="it">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Modulo</title>
    <script type="text/javascript">
      function Modulo(destinazione) {
    
         var Immobile = document.getElementById('annuncio').immobile;
    		
            if ((Immobile == "") || (Immobile == "undefined")) {
               alert("Il campo Immobile non è Valido.");
               document.getElementById('annuncio').immobile.focus();
               return false;
            }
    
            else {
               document.getElementById('annuncio').action = destinazione;
               document.getElementById('annuncio').submit();
            }
      }
    </script>
    </head>
    
    <body>
    	<form action="#" method="post" id="annuncio">
    		<fieldset>
    			<legend>Nuovo Immobile:</legend>
    				
    
    <label for="immobile">Immobile: </label>
    <input name="immobile" type="text" id="immobile" value="" size="20" /></p>
    				
    
    <input onclick="Modulo('modulo_edit_prodotto_2.asp')" type="button" name="Submit" value="Invia" /></p>
    		</fieldset>
    		</form>
    </body>
    </html>
    grazie !
    [Scambio Links a Tema] Contattatemi in Privato x + Info.

  7. #7
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Se il test non e` verificato invia il modulo una volta sola, altrimenti lo invia due volte, con quello script.

    Il test va chiamato all'evento onsubmit del form
    E NON VA FATTO PARTIRE IL FORM DALLA FUNZIONE:
    codice:
    <form action="#" method="post" id="annuncio" onsubmit="Modulo('modulo_edit_prodotto_2.asp');">
    	<fieldset>
    		<legend>Nuovo Immobile:</legend>
    			
    
    <label for="immobile">Immobile: </label>
    
    			  <input name="immobile" type="text" id="immobile" value="" size="20" /></p>
    			
    
    <input type="submit" name="Submit" value="Invia" /></p>
    	</fieldset>
    </form>
    Il JS:
    codice:
      function Modulo(destinazione) {
         var Immobile = document.getElementById('annuncio').immobile;
            if ((Immobile == "") || (Immobile == "undefined")) {
               alert("Il campo Immobile non è Valido.");
               document.getElementById('annuncio').immobile.focus();
               return false;
            } else {
               document.getElementById('annuncio').action = destinazione;
               return true;
            }
      }
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  8. #8
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Vedo che hai fatto crossposting , pratica vietata dal regolamento.
    QUI chiudo.
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

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 © 2025 vBulletin Solutions, Inc. All rights reserved.