checkbox validation

checkbox validation

by Nathan Lothamer -
Number of replies: 1

My version of Moodle is 2.1x.

I'd like to add javascript to moodle lesson content and question pages.  This javascript will hide the form submit button until the user has selected a certain amount of checkboxes. 

Has anyone tried this with Moodle and are there any example tutorials of working with javascript in Moodle?

Average of ratings: -
In reply to Nathan Lothamer

Re: checkbox validation

by Nathan Lothamer -

Here is a similar function for radio buttons:

<script>

yui().use("node", "event", function(Y){
    var nextButton = Y.one('#id_submitbutton'),
        allAnswers = Y.all('answerid');
    //FUNCTIONS
    /*When the page has loaded-
    *Hide the submit button
    */
    Y.on("domready", function(){
        nextButton.hide();
        //document.getElementById("answerDiv.input").setAttribute("class", "answers");
    });
    //When an input box is clicked,
    var clickedAnswer = function(e){
        nextButton.show();
    }
    allAnswers.on("click", clickedAnswer);    
});]

</script>

I've tried implementing it in the html block of the lesson page, but it doesnt work.  How exactly do I implement this onto a single lesson page?