Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Jquery validation - localization problem #6853


User avatar
0
p.j.keukens created

Hi,

I'm using v6.9.0 of aspnet zero on .net core.

I was setting up a form for the input of a text field with a min and max length. When the form is validated on submission, the jquery validation messages are not localized. When I add a number input onto the form, jquery validation also doesn't take the current culture into account. My app is in dutch which has a , for decimal separator and a . for thousand separator. But jquery validation doesn't take the culture into account.

Aspnet zero is fully localized right? So what am I missing?


6 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    You can debug it locally and see if it returns correctly.

    aspnet-core\src\MyCompanyName.AbpZeroTemplate.Web.Mvc\wwwroot\lib\jquery-validation\dist\localization\messages_nl.js

    https://github.com/aspnetzero/aspnet-zero-core/blob/f72d4bf9ced778e06265f1c415a8553b10cbaf3d/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Resources/ScriptPaths.cs#L24

    https://github.com/aspnetzero/aspnet-zero-core/blob/885c7b5abedd4995be15e8d70229995402ab96cd/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Areas/AppAreaName/Views/Layout/_Layout.cshtml#L147

    https://github.com/aspnetzero/aspnet-zero-core/blob/91534ec41a91da2dbd3543e6084f88e6498664a5/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Views/Account/_Layout.cshtml#L108

  • User Avatar
    0
    p.j.keukens created

    If I look in the lib folder of my web.mvc application there is no jquery-validation

    my forms are validated like this:

    if (!_$theForm.valid()) {
                    return;
    }
    
  • User Avatar
    0
    p.j.keukens created

    Okay, I'm one step closer now. The messages for jquery-validation were not in the lib directory, so I added an item to the bundles.config to copy them over and that works, the messages are now in dutch.

    But the decimal separator and thousand separator don't work yet.

    The point is seen as the decimal separator because the message is 'fill in a value larger then 0' which is the minimum value.

  • User Avatar
    0
    maliming created
    Support Team

    Try adding the following code to the scriptMappings at the bottom of bundles.json

    {
          "outputFolder": "lib/jquery-validation/dist/localization/",
          "input": [
            "node_modules/jquery-validation/dist/localization/*.js"
          ]
        }
    

    Rerun npm run create-bundles

  • User Avatar
    0
    p.j.keukens created

    just did that and that worked for the localization of the text messages.

    Now the last problem is that the jquery validation doesn't take the decimal separator and group separator for numbers into account.

    The point is seen as the decimal separator because the message is 'fill in a value larger then 0' which is the minimum value.

  • User Avatar
    0
    maliming created
    Support Team

    This should be related to jquery-validation or html etc.

    You can goole search to see.