0
I’m in need of help to include a CPF and CNPJ mask with Jquery or Js, so that it changes automatically after I click on a select, but I’m not able to include the mask inside the Razor I made.
@section scripts{
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/maskedinput")
<script>
jQuery(function ($) {
$("#xCpfCnpj").inputmask("99.999.999/9999-99");
});
</script>
}
<div>
@Html.TextBoxFor(m => m.xCpfCnpj, new
{
htmlAttributes = new
{
@class = "form-control input",
placeholder = "Cpf/Cnpj",
type = "text",
id = "xCpfCnpj"
}
})
</div>
Here I tried 2 different ways to boot
Ah I understood sorry, I will already remove and post the code, thanks for warning
– Caio Coutinho
Are you validating in the model as well? The Jquery script block is at the top or end of the view?
– Leandro Angelo
At the end of the view and I’m validating on the model
– Caio Coutinho
[Required()] public string xCpfCnpj { get; set; }
– Caio Coutinho