We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Validating decimal fields in Spanish shows error

Hello,

I have a Grid with dialog editing with some decimal fields. When using en-US localization, everything works well. But when changed to es-ES, Grid displays the fields as expected (using comma as decimal separator) and also edit dialog shows the fields with comma-delimiter for decimal places:



However, validation says the value is wrong:



Decimal fields uses DataAnnotations to define valid ranges:



I've already loaded cldr files as explained in several forum posts. The Grid definition is as follows:



I've tried several ways to achieve the right validation, even using jQuery-validation-globalize, but nothing seems to work. Please, can you help me?

Thanks in advance

5 Replies

PS Pavithra Subramaniyam Syncfusion Team December 23, 2019 07:14 AM UTC

Hi Alberto, 
 
Greetings from Syncfusion. 
 
We checked your query and would like to suggest you to use the ValidationRules property of the grid columns for setting validation rules to the columns. Please check below code snippet, 
 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col => 
{ 
                . 
                . 
    col.Field("Freight").HeaderText("Freight").ValidationRules(new { max = 99999.99, min = 0}).EditType("numericedit").Edit(new 
    { @params = new Syncfusion.EJ2.Inputs.NumericTextBox(){ 
        ValidateDecimalOnType = true, 
        Step = 1, 
        Decimals = 2, 
        Format = "C2" 
    } }).Width("160").Format("C2").Add(); 
               . 
               . 
}) 
 
Sample and documentation for your reference, 
 
 
 
Please get back to us if you have any further queries. 
 
Regards, 
Pavithra S. 



AL Alberto Levy December 27, 2019 04:31 PM UTC

Hello Pavithra,

Thanks for the quick answer. Maybe ValidationRules are the way to configure range validation but that implies I have to explicitly define that ValidationRule wherever I use that ViewModel instead of using the DataAnnotation defined for that field.

Thanks again.




PS Pavithra Subramaniyam Syncfusion Team December 30, 2019 10:01 AM UTC

Hi Alberto, 

The range validation for numerictextbox using data annotations model is working fine in our end on using Spanish culture. Please check below sample for your reference, 


We suspect you might be facing issue because of the culture files not loaded properly in your application. Can you please once ensure this in your end based on the sample we provided. 

You can cross check the above sample with your application to see if you have missed anything. 

Let us know if you have any concerns. 
 
Regards, 
Pavithra S. 



AL Alberto Levy December 31, 2019 01:15 PM UTC

Hi Pavitrha,

Thanks for the example. That led me to find out the issue was due to Syncfusion version I was using (17.1.0.38). After I've updated nugets I've been able to use Spanish format without any issue.

Thanks again.
Alberto


PS Pavithra Subramaniyam Syncfusion Team January 2, 2020 04:54 AM UTC

Hi Alberto, 
 
Thanks for your update. 

We are glad to know that your issue has been resolved. 

Please contact us if you need any further assistance on Grid. As always, we will be happy to assist you.  

Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon