-3
I’m using the lib of maskedinput jquery to format the data field, but I would like the field to be formatted as follows... 99/9999
Eu fiz essa tentativa, mas não deu certo;
$(function() {
$(".date").mask("99/9999");
});
HTML
<div class="col-sm-2">
<input autocomplete="off" id="idPeriodoInicio" class="form-control data listar_uj" name="periodoInicio" id="periodoInicio" placeholder="Período Inicial">
</div>
What I could do to format the field for month and year?
Look how it is today!
Maybe it didn’t work out because the class is wrong. It would have to be
$(".data")
and not$(".date")
. Do not forget also to load the lib.– Sam
unfortunately did not resolve.
– wladyband
So there are more things wrong, because with the code you put in the question just changing from
.date
for.data
generated the expected result: https://jsfiddle.net/o14tkpe3/.– Woss
By the image shown in the question, the field already has a mask and you want to change it?
– Sam
Somewhere in your system is there not something like
$(".date").mask("99/99/9999");
? maybe it’s giving conflict– Thiago Costa
Yes, because it is picking up already defined settings of masks, you can take the class ". date" of your input and put a custom class with the mask in the desired format.
– Bruno