1
I’m using a Remark component that has a data-plugin="formatter"
where it applies a CEP mask to field
. The field
has a size of 8 characters, but the mask has 9 because of the "-"
(Ex: 29780-000). When saving the record the JavaScript Validation
validates on the client side and does not give the post because of the character rating.
Viewmodel:
[DisplayName("CEP")]
[Required(ErrorMessage = "O campo CEP é obrigatório")]
[MaxLength(8, ErrorMessage = "O campo {0} deve ter no máximo {1} caracteres")]
public string CEP { get; set; }
View:
<div class="col-md-2">
<label asp-for="PessoaFisicaViewModel.PessoasFisicasEnderecosViewModel[i].CEP" class="control-label lb-cep">CEP</label>
<input type="text" asp-for="PessoaFisicaViewModel.PessoasFisicasEnderecosViewModel[i].CEP" data-plugin="formatter" data-pattern="[[99999]]-[[999]]" class="form-control txt-cep" />
<span asp-validation-for="PessoaFisicaViewModel.PessoasFisicasEnderecosViewModel[i].CEP" class="text-danger validation-cep"></span>
</div>
Is there any configuration or way to have only numbers sent when giving post
? In the Desktop applications you can configure the mask not to be saved, but in app web
I don’t know if there’s a way. Someone knows how to help me?
Big hug!!! :)
Don’t you just have to change the default to date-Pattern="[[99999999]]" ? Or Do you want to keep the dash?
– George Wurthmann
Because it is @George Wurthmann, in data-Pattern I specify the format of Mask with the dash so that it is easier for the user. Only that the trace occupies space in the field... I wish that the trace was not considered... In fact, that the characters of Mask were not considered.. only the numbers...
– Master JR