Reputation: 1982
I have an ASP.NET project where I use a Kendo Numeric TextBox element. I've set a min value of 200 (in the example) and when the user enters a lower value, the input changes automatically to the min value.
Is there any way, or a property, that would enable me to avoid this and show the field in red or an error intead, rather than automatically correct to the min value?
This is my code:
@Html.Kendo()
.NumericTextBoxFor(model => model.Example)
.HtmlAttributes(new { style = "width: 80px;" })
.Format("#")
.Min(Model.MinValue)
EDIT: I forgot to say that the min value came from a web service.
Upvotes: 1
Views: 1391
Reputation: 6784
You can use something like this instead that will produce the same requirements you need
public class YourModel
{
[IntegerValidator(MinValue = 200, MaxValue = int.MaxValue, ExcludeRange = true)]
public int Example{get;set;}
}
to get more information about this idea, please check this link IntegerValidator
and you can use for example [Range(200,int.MaxValue)]
for integer and [Range(200,double.MaxValue)]
for double to specify only the min value
this will work with client side validation
and if you don't want to go with this idea, i think you can handle the client side event onchange for the control numerictextboxfor and you call for e.preventdefault(); and then you can handle the value as you want
hope this will help you
Upvotes: 0