-1
I am doing a project in MVC and with the use of jQuery I made CPF mask as below:
$(document).ready(function()
{
$(".cpf").mask("999.999.999-99");
$(".cpf").addClass("form-control");
});
Follow my div
:
<div class="form-group">
@Html.LabelFor(model => model.Cliente_CPF, htmlAttributes: new { @class = "control-label" })
<div>
@Html.EditorFor(model => model.Cliente_CPF, new { htmlAttributes = new { @class = "cpf" } })
@Html.ValidationMessageFor(model => model.Cliente_CPF, "", new { @class = "text-danger" })
</div>
</div>
The mask is working properly, but I need this information to be recorded in my BD without the mask! Just the CPF numbers.
Like I should do?
I believe that if you add a function to the event
submit
form and within it do something like$(".cpf").val($(".cpf").val().replace(/^\D+/g, ''))
would work as it would be removing any character that is not a digit.– Woss