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

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

2 Answers 164 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Songbackerteam
Top achievements
Rank 1
Songbackerteam asked on 14 Mar 2013, 01:19 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 18 Mar 2013, 08:45 AM
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!
0
Songbackerteam
Top achievements
Rank 1
answered on 18 Mar 2013, 09:23 AM
Hello Georgi,

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

Thanks,
PSSPL
Tags
NumericTextBox
Asked by
Songbackerteam
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Songbackerteam
Top achievements
Rank 1
Share this question
or