<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<script src="https://rawgit.com/crissdev/Knockout-Validation/master/dist/knockout.validation.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div class="container">
<div class="checkbox">
<label>
<input type="checkbox" data-bind="checked: isChecked"> Check me out
</label>
</div>
</form>
</div>
</body>
</html>
// Code goes here
jQuery(function() {
'use strict';
ko.validation.init({errorMessageClass: 'help-block'}, true);
ko.validation.utils.insertAfter = function (node, newNode) {
console.log(node, newNode);
var nodeNext = node.nextSibling;
var nextEl = node.nextElementSibling;
if (nextEl && nextEl.tagName == 'LABEL')
nodeNext = nextEl.nextSibling;
node.parentNode.insertBefore(newNode, nodeNext);
};
var vm = {
isChecked: ko.observable().extend({
validation: {
validator: function(value) {
return false;
},
message: 'Value must be checked'
}
})
};
ko.applyBindings(vm);
vm.isChecked.valueHasMutated();
});
/* Styles go here */