Validation with custom rule for data in either AutoComplete or DropDownList

2 posts, 0 answers
  1. Sean
    Sean avatar
    15 posts
    Member since:
    Sep 2013

    Posted 23 Oct 2013 Link to this post

    How can I validate whether input has been entered in an AutoComplete or a selection has been made in a DropDownList. If neither is true then it should fail validation. I'm just figuring out the Kendo Validation and if there was a length requirement maybe I'd be on the right track. Can someone suggest a successful way to validate this scenario?

    Here's where I started:
    <div id="cboSearchStringValidate1">
        <input type="search" id="cboSearchString1AC" />
        <input id="cboSearchString1DDL" />

    $("#btnSearch").click(function () {                                         alert('start to validate');                                             $("#cboSearchStringValidate1").kendoValidator({
    rules: {
                                                           customruleSearchStrings1: function (input) {                                if (cboSearchString1AC.length == 0 && $(cboSearchString1DDL).val == ""){
     return input.val() === "true";
    }                                                           return true;                                                       }
    },                                                   messages: {                                                       customruleSearchStrings1: "Search must not be empty"                                                 }                                               });                                               alert('validate checked');                                           
    I think this needs to be in here somewhere, but not sure if I have the whole thing put together properly.
    var validator1 = $("#cboSearchStringValidate1").kendoValidator().data("kendoValidator");
    if (!validator1.validate()) {
        alert("validated search strings 1");
        alert('yes, we are valid');
    else {
        alert("no such luck");
    Thanks in advance for enlightening me ;)
  2. Kiril Nikolov
    Kiril Nikolov avatar
    2596 posts

    Posted 25 Oct 2013 Link to this post

    Hello Todd,

    You will need to initialize the Kendo UI Validator, before you click the button for validation. Please check the following example, showing a possible implementation:
    Kiril Nikolov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top