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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Validating decimal fields in Spanish shows error

Thread ID:

Created:

Updated:

Platform:

Replies:

150117 Dec 20,2019 10:25 PM UTC Jan 2,2020 04:54 AM UTC ASP.NET MVC - EJ 2 5
loading
Tags: Grid
Alberto Levy
Asked On December 20, 2019 10:43 PM UTC

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

Pavithra Subramaniyam [Syncfusion]
Replied On 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. 


Alberto Levy
Replied On 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.



Pavithra Subramaniyam [Syncfusion]
Replied On 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. 


Alberto Levy
Replied On 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

Pavithra Subramaniyam [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon