$("#myform").kendoValidator().data("kendoValidator") is undefined

3 posts, 0 answers
  1. Drew
    Drew avatar
    2 posts
    Member since:
    Jan 2013

    Posted 23 Jan 2013 Link to this post


    I am trying to follow the very simple validation example. I have this written:

        $(document).ready(function () {
            var validatable = $("#myform").kendoValidator().data("kendoValidator");
            $("#save").click(function () {
                if (validatable.validate()) {
                } else {
                    alert('Not valid');

    and html:

        <div id="myForm">
                <label for="Name">Name</label>      
                <input type="text" id="Name" name="Name" required/>
                <label for="Age">Age</label>     
                <input type="text" id="Age" name="Age">
                <label for="Phone">Phone</label>
                <input type="text" title="Phone Number" id="Phone" pattern="\d{10}" validationMessage="please enter a ten digit phone number"/>
                <button id="save" type="button" class="k-button"></button>
                <!--<input type="submit" id="Submit" value="Submit" @*onclick="checkValidation()"*@/>-->

    it says that 'validatable' is not defined. But what's weird is when I step through the code in Firebug, it shows the proper return when I call manually $("#myform").kendoValidator().data("kendoValidator"). It seems only if I put it in a variable, that variable is undefined.

    Can anyone help? maybe I am missing some JS references? Which ones do I need for this? please help.

  2. Alexander Valchev
    Alexander Valchev avatar
    2873 posts

    Posted 24 Jan 2013 Link to this post

    Hi Drew,

    The selector is not correct:
    <div id="myForm"></div>
    var validatable = $("#myform").kendoValidator().data("kendoValidator");

    I would like to remind you that selectors are case sensitive.

    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Drew
    Drew avatar
    2 posts
    Member since:
    Jan 2013

    Posted 24 Jan 2013 Link to this post

    thanks,,, such a silly mistake..

    I should also note, that I was using jQuery version 1.6.2. It seems this functionality requires jQuery 1.8.2. As It didn't work with the old version of jQuery. I don't know how that older version got in my project

    thanks again
Back to Top