seularts 0 Light Poster

I tested over and over and it seems there is something conflicting between these 2 scripts: bootstrap toggle and jquery validator. If I remove data-toggle=" toggle" the checkbox is required for validation, otherwise it just passes regardless of being checked or not!

<form id="regiration_form" action="action.php"  method="post">

    <h1></h1>

    <fieldset>

        <h2>Pasul 1: Sa facem cunostinta!</h2>

        <h1></h1>

            <div class="form-group">

                <label for="nume"><i class='fa fa-id-card-o'></i> Nume</label>
                <input type="text" class="form-control" id="nume" name="nume" placeholder="ex: Ion Popescu">

            </div>

            <div class="form-group">

                <label for="email"><i class='fa fa-envelope-o'></i> Adresa E-Mail</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="ex: exemplu@domeniu.ro">

            </div>

            <div class="form-group">

                <label for="companie"><i class='fa fa-cog'></i> Companie</label>
                <input type="text" class="form-control" id="companie" name="companie" placeholder="ex: SC Companie SRL">

            </div>

            <div class="form-group">

                <label for="telefon"><i class='fa fa-volume-control-phone'></i> Telefon</label>
                <input type="tel" class="form-control" id="telefon" name="telefon" placeholder="ex: 0730 234 634">

            </div>

            <div class="form-group">

                <label for="tsm" class="label-text"><i class='fa fa-check-square-o'></i> Sunt de Acord (Termeni si Conditii)</label>
                <input type="checkbox" name="tsm" data-toggle="toggle" data-on="<i class='fa fa-cogs'></i> DA" data-off="<i class='fa fa-eye-slash'></i> NU" data-onstyle="success" data-offstyle="warning">

            </div>

        <button type="button" class="next btn btn-info"><i class='fa fa-plus'></i> Adauga</button>

    </fieldset>

    ... other steps ...

    </form>

and the validation extended script:

$(document).ready(function(){
    var current = 1,current_step,next_step,steps;
    steps = $("fieldset").length;
        $("#regiration_form").validate({
        /* errorLabelContainer: "#error-note",
        wrapper: "span", */
        rules: {
            nume: "required",
            email: "required",
            companie: "required",
            telefon: "required",
            tsm: "required",
            domeniu: "required",
            buget: {
                required: true,
                minlength: 3
            }
        },
        messages: {
            nume: "Adauga Numele Tau",
            email: "Adauga Adresa Ta de E-Mail",
            companie: "Adauga Numele Companiei",
            telefon: "Adauga Numarul Tau de Telefon",
            tsm: "Bifeaza DA, daca esti de acord cu Termenii si Conditiile CautPublicitate.ro",
            domeniu: "Adauga Domeniul de Activitate al Companiei",
            buget: "Specificati Bugetul Lunar"
        }
    })
    $(".next").click(function(){
        if($("#regiration_form").valid()) {
            current_step = $(this).parent();
            next_step = $(this).parent().next();
            next_step.show();
            current_step.hide();
            setProgressBar(++current);
        }
    });
    $(".previous").click(function(){
        current_step = $(this).parent();
        next_step = $(this).parent().prev();
        next_step.show();
        current_step.hide();
        setProgressBar(--current);
    });
    setProgressBar(current);
    // Change progress bar action
    function setProgressBar(curStep){
        var percent = parseFloat(100 / steps) * curStep;
        percent = percent.toFixed();
        $(".progress-bar")
            .css("width",percent+"%")
            .html(percent+"%");     
    }
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.