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

MVC NumericTexbox min/max validation message not showed

2 Answers 487 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Leonard
Top achievements
Rank 1
Leonard asked on 28 Feb 2016, 11:54 PM

I defened in my model a range for my field:

[Range(1875,2043)]
public int? SpringA1 {get;set;}

I have a grid with a template editor with my field :

@Html.kendo().IntergerTexBoxFor(model => model.SpringA1)

My problem is when I enter a value out of range the control change the value to min or max range instead of showing a range error message.

ex : if You enter a value of 3000 with the keyboard and lose focus from the input or save the form, the value will be rounded to the max value of 2043.

--------------------------------

If I init de Deferred property to true

@Html.kendo().IntergerTexBoxFor(model => model.SpringA1).Deferred(true)

the message is correctly showed but the control is not rendered properly, no css and no span for increment the value.

 

what I can do for prevent the control to round the value and show the message.

Thx

 

   

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 02 Mar 2016, 09:56 AM
Hello Leonard,

The MVC NumericTextBox extension is designed to retrieve min/max range from the the Model property metadata. When the Model property is decorated with Range attribute, the widget will retrieve the range values and will set its min/max options.

If you would like to avoid this behavior, then you will need to remove the defined min/max options manually:
@Html.kendo().IntergerTexBoxFor(model => model.SpringA1).Min(null).Max(null)

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Leonard
Top achievements
Rank 1
answered on 02 Mar 2016, 08:39 PM
Thank you, works like i expected.
Tags
NumericTextBox
Asked by
Leonard
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Leonard
Top achievements
Rank 1
Share this question
or