Empty

by stevescotthome

HTML

<script src="http://cdn.kendostatic.com/2012.1.322/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.default.min.css">
<form id="container">
    <input id="date" required validationMessage="Nope" />
    <span class="k-invalid-msg" data-for="amount"></span>
    <hr />
    <input name="foo" type="radio" value="1" required /> Yes
    <input name="foo" type="radio" value="2" required/> No 
    <span class="k-invalid-msg" data-for="foo"></span> <br/>
    
    <button>Submit</button>
</form>

JavaScript

$("#date").kendoDatePicker();

$("form").kendoValidator({
    rules: {
        radio: function(input) {
            if (input.filter("[type=radio]") && input.attr("required")) {        
                return $("form").find("[name=" + input.attr("name") + "]").is(":checked");
            }
            return true;
        }
    },
    messages: {
        radio: "Select one of the options"
    }
});