Commit e039d7fc by Xavier Antoviaque

Merge pull request #34 from anantasty/MRQ/MCQ_validators

Mrq/mcq validators
parents 643041bf 7b010fea
...@@ -45,6 +45,10 @@ function MessageView(element) { ...@@ -45,6 +45,10 @@ function MessageView(element) {
function MCQBlock(runtime, element) { function MCQBlock(runtime, element) {
return { return {
init: function(options) {
$('input[type=radio]', element).on('change', options.blockValidator);
},
submit: function() { submit: function() {
var checkedRadio = $('input[type=radio]:checked', element); var checkedRadio = $('input[type=radio]:checked', element);
...@@ -104,12 +108,24 @@ function MCQBlock(runtime, element) { ...@@ -104,12 +108,24 @@ function MCQBlock(runtime, element) {
messageView.clearPopupEvents(); messageView.clearPopupEvents();
} }
} }
},
validate: function(){
var checked = $('input[type=radio]:checked', element);
if (checked.length) {
return true;
}
return false;
} }
}; };
} }
function MRQBlock(runtime, element) { function MRQBlock(runtime, element) {
return { return {
init: function(options) {
$('input[type=checkbox]', element).on('change', options.blockValidator);
},
submit: function() { submit: function() {
var checkedCheckboxes = $('input[type=checkbox]:checked', element), var checkedCheckboxes = $('input[type=checkbox]:checked', element),
checkedValues = []; checkedValues = [];
...@@ -161,6 +177,14 @@ function MRQBlock(runtime, element) { ...@@ -161,6 +177,14 @@ function MRQBlock(runtime, element) {
}); });
}); });
},
validate: function(){
var checked = $('input[type=checkbox]:checked', element);
if (checked.length) {
return true;
}
return false;
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment