Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Cream
    Registrato dal
    Feb 2002
    Messaggi
    534

    Function Checkbox da modificare

    salve
    ho uno script di controllo di form ottimo,con un solo problema.
    il controllo sulle checkbox non mi funziona se di default setto tutte le caselle checked,ma vorrei che fosse possibile,mi è necessario!!
    l'importante per me è che le caselle spuntate alla fine siano > 0,non altro.
    grazie
    questa è la parte di codice incriminata:
    --------------------------------------------

    function validateCheckbox(formObj, minC, maxC) {
    var objName = formatName(formObj);
    var formObj = formObj.form.elements[formObj.name];
    var checkTotal = formObj.length;
    var checkCount = 0;

    if (maxC == 999) maxC = checkTotal;
    for (var i=0; i<checkTotal; i++) {
    if (formObj[i].checked) checkCount++;
    }
    if (checkCount < minC || checkCount > maxC) {
    if (fv['groupError']) { addError(formObj); return true; }
    alert('Please select between '+minC+' and '+maxC+' options for '+objName+'.\nYou currently have '+checkCount+' selected');
    for (i=formObj.length-1; i>=0; i--)
    errorProcess(formObj[i],0,1);
    return false;
    }
    return true;
    }
    -------------------------
    grazie 1000

  2. #2
    Reale_Augello
    Guest

    Prova...

    ... con questa piccola modifica:

    codice:
    function validateCheckbox(formObj, minC, maxC) { 
    var objName = formatName(formObj); 
    var formObj = formObj.form.elements[formObj.name]; 
    var checkTotal = formObj.length; 
    var checkCount = 0; 
    
    if (maxC == 999) maxC = checkTotal; 
    for (var i=0; i<checkTotal; i++) { 
    if (formObj[i].checked) checkCount++; 
    } 
    if (checkCount < minC || checkCount > maxC) { 
    if (fv['groupError']) { addError(formObj); return true; } 
    alert('Please select between '+minC+' and '+maxC+' options for '+objName+'.\nYou currently have '+checkCount+' selected'); 
    for (i=formObj.length-1; i>=0; i--) 
    errorProcess(formObj[i],0,1); 
    return false; 
    } 
    if (checkCount==0) {
    alert("Almeno un checkbox deve essere selezionato.");
    return false;
    }
    return true; 
    }
    Fammi sapere !

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.