Problem with Masked Fields

0

Hello, I'm using the masked input plugin to mask some of the decimal fields!

However, when I submit the form this field arrives as null in the controller class. I already looked and could not find anything about it.

Can anyone help me? Thanks in advance.

Follow the code.

Model

 [Display(Name = "Telefone")]
 public decimal? TELEFONE_FUN { get; set; }

Controller

[HttpPost]
        public ActionResult Add_Funcionarios(FUNCIONARIOS funcionario)
        {
            if (ModelState.IsValid)
            {
                //recupera o nome do usuario da sessao
                GRAgro.Models.USUARIOS usuario =        (GRAgro.Models.USUARIOS)Session["usuario"];
                string nome = User.Identity.Name;

                // seta o id do usuario vindo da sessao
                funcionario.ID_USU = UsuarioCont.PegaIdUsuarioLogado(nome);
                FuncionarioRep.Add_Funcionarios(funcionario);

                cadHistorico(historico, funcionario,"Cadastro do Funcionario(a):");
                TempData["Feedback_cadastro"] = "Funcionario "+funcionario.NOME_FUN+" Cadastrado com Sucesso!";
                return RedirectToAction("CadastradoComSucesso", "Feedback");
            }
            else
            {
                TempData["teste"] = "nao cadastrado";
                return View();
            }
        }

View

<div class="form-group">
                                    @Html.LabelFor(model => model.TELEFONE_FUN)
                                    @Html.TextBoxFor(model => model.TELEFONE_FUN, new { @class = "form-control" })
                                    @Html.ValidationMessageFor(model => model.TELEFONE_FUN)
                                </div>

Jquery

$("#TELEFONE_FUN").mask("(99) 99999-9999");
    
asked by anonymous 10.12.2015 / 13:53

1 answer

0

Hello, if I understood correctly the "PHONE_FUN" is declared in the model as number, then when you pass the masked value goes the parentheses and the hyphen together, then the bad. Try to "clean" it before sending or declare the "PHONE_FUN" field so that you can receive these characters.

    
10.12.2015 / 19:03