Hi,
I'm using the numeric text box as follows:
The model property 'MaintenanceYearlyAmount' has the following attributes for validation:
When testing this I get the following results:
I'm using the numeric text box as follows:
<
div
class
=
"col-md-7 col-sm-6"
>
@(Html.Kendo().NumericTextBoxFor(m => m.MaintenanceYearlyAmount).Decimals(1).Deferred(true))
@Html.ValidationMessageFor(m => m.MaintenanceYearlyAmount)
</
div
>
The model property 'MaintenanceYearlyAmount' has the following attributes for validation:
[Display(Name =
"Annual Maintenance"
)]
[Required]
[Range(0,1000)]
[ToolTip(
"Dependant's Annual Maintenance"
)]
public
decimal
? MaintenanceYearlyAmount
{
get
{
return
ModelEntity.MaintenanceYearlyAmount;
}
set
{
ModelEntity.MaintenanceYearlyAmount = value;
}
}
When testing this I get the following results:
- I enter 999.56 - It rounds up to 999.60 (Why is it showing the additional zero at the end when I've specified only 1 decimal?)
- I enter 1111 and tab off the control - I get a valid validation message of 'Please enter a value less than or equal to 1000' AND it automatically changes the value to 1000 (is there a way to stop this from happening? The user should be warned, but it's there responsibility to change the value not to have it automatically changed. They might have entered 9845 accidentally adding the 5 at the end and instead of just deleting the 5 they have to type the number out again.
- I remove the Range validation and keep only the Required validation.
- I delete the current value for MaintenanceYearlyAmount and for Full Name (which is a normal Microsoft textbox and is required in the model) and click save. - Full name correctly shows its validation message, but the Kendo numeric textbox doesn't. This is where the problem is. I'm not sure why the client side validation doesn't fire correctly or show the validation message. If I add the Full name value back and click submit/save again, Full name passes, the form submits and server side validation fails sending the form back with the correct message under the MaintenanceYearlyAmount input. So bottom line is that the validation works server side, but not client side for the Required Validator.