Wrong Format Errors

Mvc3 and Mvc2 includes a client side validation provider that takes care of wrong format errors of numeric fields on the client side. However, its error message is not customizable.

In the Mvc Controls Toolkit we extended it to allow the customization of the message error, and to allow also the check of Date and Time fileds on the client side, with customizable messages.

In order to customize the numeric wrong format error message it is enough to add the following code in the Global.asax:


 MVCControlsToolkit.Core.ClientDataTypeModelValidatorProviderExt.ErrorMessageResources = typeof(MyResourceType);
            MVCControlsToolkit.Core.ClientDataTypeModelValidatorProviderExt.NumericErrorKey = "MyCustomKey";


Where MyResourceType is the resource file (and also the resource type) where we wolud like to include the customized message; while MyCustomKey is the key containing the message.

To add the validation check for DateTime on the client side, similarly we need to add: 


MVCControlsToolkit.Core.ClientDataTypeModelValidatorProviderExt.ErrorMessageResources = typeof(MyResourceType);
            MVCControlsToolkit.Core.ClientDataTypeModelValidatorProviderExt.DateTimeErrorKey = "MyDateError";


All validation checks takes into account the format specified in the current culture on the server if adequate globalizationn settings are provided.

Last edited Jun 22, 2014 at 10:32 AM by frankabbruzzese, version 3


No comments yet.