Need solution to support Data-annotations client side validations in MVC3

3 posts, 1 answers
  1. Songbackerteam
    Songbackerteam avatar
    6 posts
    Member since:
    Mar 2013

    Posted 14 Mar 2013 Link to this post

    Hi,

    I have implemented NumericTextbox from Kendo-UI-web controls.

    Case-1: I just want that when user enters an amount (e.g. 9000) more than allowed max. amount (e.g. 5000), then on lost focus of the input the entered amount (i.e. 9000) is replaced with max. allowed amount (i.e. 5000) by kendo UI. Hence my RangeValidator from Data-annotation doesn't get fired anytime. Our client wants that validation instead of automatic replacement. Please guide us how to achieve this.

    Case-2: As the kendo-JS hides the original input and places another to show. This behavior prevents RequiredValidator from data-annotations to get fired at client-side, which is badly required by our client. Please guide us how to achieve this.

    Feel free if you find any difficulty to understand above mentioned case studies.

    Waiting for quick reply,

    Thanks in advance,
    PSSPL
  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 18 Mar 2013 Link to this post

    Hello,

     
    Straight up to your questions:

    #1:
    Kendo NumericTextBox for ASP.NET MVC sets its min/max values retrieving them from the Range attribute of the Model's property. Once min and max range of the widget is defined then values which are out of this range will not be allowed. You can overcome this behavior setting min/max property of the widget to null:

    @(Html.Kendo().NumericTextBox<double>()
        .Name("percentage")
        .Min(null)
        .Max(null)
    )

    #2:
    Since jquery.validate 1.9, hidden input elements are not validate. Nevertheless, this can be changed setting ingore option to empty string:
    <script>
    $.validator.defaults.ignore = "";
    </script>
    This code should be placed right after the scripts of jquery validate.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Songbackerteam
    Songbackerteam avatar
    6 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    Hello Georgi,

    Thanks much for your reply. You solved my both issues. Your solution worked well.

    Thanks,
    PSSPL
Back to Top