KendoUI Validate Numeric Textbox

The KendoUI validation does not work with kendo-numeric-textbox. I get the following error. "An invalid form control with name='amount' is not focusable. "

See example below. Try submit and see error in browser console.

http://plnkr.co/edit/pXpXexPq3u9xAzzpKR8Y?p=preview

I´m trying to get required popup "Please fill out this field" with the Kendo numeric textbox.

Can anyone help?

Upvotes: 3

Views: 6500

Answers (1)

Rick S
Rick S

Reputation: 6586

Seems to be some strange issue with hidden fields using the kendoNumericTextBox.

I was able to get it to work using the kendo validator: [See here]

There's also an interesting article [Here]

Updated Code:

$(document).ready(function () {


   $("#amount").kendoNumericTextBox();


    var validator = $("#testForm").kendoValidator().data("kendoValidator"), status = $(".status");
    $("form").submit(function(event) {
                    event.preventDefault();

                    if (validator.validate()) {
                        status.text("Valid")
                            .removeClass("invalid")
                            .addClass("valid");
                    } else {
                        status.text("Not Valid")
                            .removeClass("valid")
                            .addClass("invalid");
                    }
                });

});

Upvotes: 3

Related Questions