Reputation: 11
I use ASP.NET Core 6.0 and want to create an exclusively German-language application. So far everything works fine, not least because of the good content here.
However, I now have a problem that the client-side validation of numbers in German notation ("1.234.567,89") simply doesn't work and only the US format ("1,234,567.89") is accepted. When entering dates, however, it works fine. I have also been able to successfully implement the German notifications.
The server-side validation also works when the form sends "1.234.567,89", this value is also properly recognized, etc. I also added the <html lang="de-de">
language tag to the main HTML file.
So far I've helped myself by turning off the client-side validation for the relevant fields with <input data-val="false" ..... />
.
This code is also stored in Program.cs:
var supportedCultures = new[] { new CultureInfo("de-DE") };
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("de-DE"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("de-DE");
CultureInfo.CurrentCulture = new CultureInfo("de-DE");
CultureInfo.CurrentUICulture = new CultureInfo("de-DE");
Who can help me?
Upvotes: 0
Views: 657
Reputation: 11
After I manually downloaded the appropriate jquery validation package, explicitly specified the German validation methods and languages and entered script snippets in the shared validation, it works wonderfully.
<script src="~/plugins/jquery-validation/jquery.validate.min.js"></script>
<script src="~/plugins/jquery-validation/localization/messages_de.min.js"></script>
<script src="~/plugins/jquery-validation/localization/methods_de.min.js"></script>
<script src="~/plugins/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
Upvotes: 1