Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    CheckBox Obbligatoria (2 non 1)

    Ciao a tutti...
    con il codice che segue (preso dalla sezione javascript di html.it) controlla se un checkbox è seleizionato,prima di abilitare il tasto "Submit"
    codice:
    <script>
    
    //"Accept terms" form submission- By Dynamic Drive
    //For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
    //This credit MUST stay intact for use
    
    var checkobj
    
    function agreesubmit(el){
    checkobj=el
    if (document.all||document.getElementById){
    for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
    var tempobj=checkobj.form.elements[i]
    if(tempobj.type.toLowerCase()=="submit")
    tempobj.disabled=!checkobj.checked
    }
    }
    }
    
    function defaultagree(el){
    if (!document.all&&!document.getElementById){
    if (window.checkobj&&checkobj.checked)
    return true
    else{
    alert("Please read/accept terms to submit form")
    return false
    }
    }
    }
    
    </script>
    
    </head>
    <body >
    
    
    
    <div align="center">
    
    
    <form name="agreeform" onSubmit="return defaultagree(this)" action="">
    <textarea class="codecontainer" rows="8" name="S1" cols="45" wrap="virtual">Accetta le condizioni</textarea>
    
    <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">Accetto
    
    <input type="Submit" value="Submit!" disabled>
    </form>
    
    <script>
    //change two names below to your form's names
    document.forms.agreeform.agreecheck.checked=false
    </script>
    Ma se io volessi che le checkbox da sezionare fossero 2... come devo intervenire?
    ho provato ma mi abilita il tasto sempre e cmq anche se solo uno dei 2 e selezionato...

    come posso fare?

    grazie tante per l'aiuto

  2. #2

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.