Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Allowing decimals with both a comma and a period in ASP .Net Core web app

$
0
0

In an ASP .Net Core 1.1 MVC web app, is there any way to allow the user to enter decimal fields with either a decimal comma or a decimal point? Currently (living in South Africa with local server) the user needs to enter decimals using a decimal comma in my forms. If he uses a decimal period (in a textbox for entering latitude and longitude coordinates), ModelState.IsValid is false in the controller. So::

[HttpPost]
[ValidateAntiForgeryToken]
[Authorize]
public async Task<ActionResult> Create(PropertyViewModel vm)
{    if (!ModelState.IsValid) // is false.        return BadRequest(ModelState);
}


and the error is "The value '-25.728352' is not valid for Latitude."


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>