This is a migrated thread and some comments may be shown as answers.

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

2 Answers 878 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 23 Jan 2013, 09:13 PM
hi,

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()) {
                alert('Valid');
            } else {
                alert('Not valid');
            }
        });
    });

and html:

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

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.

thanks!

2 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 24 Jan 2013, 11:24 AM
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.

Regards,
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!
0
Drew
Top achievements
Rank 1
answered on 24 Jan 2013, 03:51 PM
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
Tags
Validation
Asked by
Drew
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Drew
Top achievements
Rank 1
Share this question
or