0
Fichaviewmodel.Cs
[Required(ErrorMessage = "A altura é obrigatória.")]
public decimal Altura { get; set; }
fiche.js
$("#Altura").mask("9.99");
Fichacontroller.Cs
[HttpPost]
public ActionResult Cadastro(FichaViewModel fichaView)
{
if (ModelState.IsValid)
{
...
}
return View(fichaView);
}
Value '1.70' is not valid for Height.
How do I make the Height accept the past value?
When leaving the mask with comma (9.99) the validation recognizes as text, and with dot (9.99) gives the error as mentioned. So I decided to leave the Property as string and when mapping from Fichaviewmodel to Fichadomain, with Automapper, the conversion normally occurs.
Rafael, a while ago I asked this question: What is the correct way to use the float, double and decimal types?
– Marconi
Hello @Marconi! So I’ve tested double too, but the problem is the same.
– Raphael
Checks whether the variable
fichaView
is receiving theAltura
straight.– Marconi
It receives the value 0, but when I see in the Modelstate errors, the message that gives is the one I mentioned.
– Raphael