ASP.NET MVC: Problem assigning decimal value

0

ViewModel.cs Tab

[Required(ErrorMessage = "A altura é obrigatória.")]
public decimal Altura { get; set; }

ficha.js

$("#Altura").mask("9.99");

Controller.cs Tab

[HttpPost]
public ActionResult Cadastro(FichaViewModel fichaView)
{
    if (ModelState.IsValid)
    {
       ...
    }

    return View(fichaView);
 }
  

The value '1.70' is not valid for Height.

How do I get the height to accept the past value?

When you leave the mask with a comma (9.99) the validation recognizes as text, and with point (9.99) gives the error as I mentioned. So I decided to leave the property as a string and when mapping the ViewModel Tab to the DataManager with AutoMapper, the conversion normally occurs.

    
asked by anonymous 07.12.2017 / 16:00

0 answers