My field that loads cpf is this:
<div class="form-group">
@Html.LabelFor(model => model.cpf, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.cpf, new { htmlAttributes = new { @class = "form-control", @id = "cpf" } })
@Html.ValidationMessageFor(model => model.cpf, "", new { @class = "text-danger" })
</div>
</div>
and on the submit
button I call function
on the click:
<input type="submit" value="Create" class="btn btn-default" onclick="replaceCpf();"/>
My js function:
function replaceCPF(cpf) {
return cpf.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
}
How can I parameter the cpf?