follow as ta in the documentation:
put this in your 'head'
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js'></script>
in your input will stay like this:
<input id="cpf" name="cpf" type="text" class="cpf" value="{variavel cpf}">
and at the end put this
<script>
$(document).ready(function(){
$('.date').mask('00/00/0000');
$('.time').mask('00:00:00');
$('.date_time').mask('00/00/0000 00:00:00');
$('.cep').mask('00000-000');
$('.phone').mask('(91) 00000-0000');
$('.phone_with_ddd').mask('(00) 0000-0000');
$('.phone_us').mask('(000) 000-0000');
$('.mixed').mask('AAA 000-S0S');
$('.cpf').mask('000.000.000-00', {reverse: true});
$('.cnpj').mask('00.000.000/0000-00', {reverse: true});
$('.money').mask('000.000.000.000.000,00', {reverse: true});
$('.money2').mask("#.##0,00", {reverse: true});
$('.ip_address').mask('0ZZ.0ZZ.0ZZ.0ZZ', {
translation: {
'Z': {
pattern: /[0-9]/, optional: true
}
}
});
$('.ip_address').mask('099.099.099.099');
$('.percent').mask('##0,00%', {reverse: true});
$('.clear-if-not-match').mask("00/00/0000", {clearIfNotMatch: true});
$('.placeholder').mask("00/00/0000", {placeholder: "__/__/____"});
$('.fallback').mask("00r00r0000", {
translation: {
'r': {
pattern: /[\/]/,
fallback: '/'
},
placeholder: "__/__/____"
}
});
$('.selectonfocus').mask("00/00/0000", {selectOnFocus: true});
});
</script>
or try this:
$string = "33322255588";
$string1 = substr("$string", 0, 3);
$string2 = substr("$string", 3, 3);
$string3 = substr("$string", 6, 3);
$string4 = substr("$string", 9, 10);
echo $string1.'.'.$string2.'.'.$string3.'-'.$string4;
to save in the bank you have to take the formatting then you can do it:
$string = "333.222.555-88";
$result = explode('.', $string );
$result2 = explode('-', $result[2] );
$result3 = $result[0].$result[1].$result2[0].$result2[1];
echo $result3;
It did not work, the mask is not yet applied, it is coming from the bank without mask and so remains
– Stand Alone
ta ta la vc ta displaying this within an input ?
– Schielke
that way:
<input required="required" type="text" class="form-control" id="Cpf" name="Cpf" placeholder="Ex.: 010.011.111-00" maxlength="14">
– Stand Alone
when you type inside this input it formats?
– Schielke
Yeah, it just doesn’t work when it comes from the bank...
– Stand Alone
ta la so convert the values, vc ta using php in the back?
– Schielke
I edited my answer, look at it at the end of my answer there’s one thing I did in php, I don’t know which language in the back q vc are using, but basically I formatted the string using php by taking each possible and putting '-' and '.' because Cpf’s string number value never changes, this way this is a solution, just remember that you have to treat this value when saving again in the bank
– Schielke
I’m using c#, I don’t want to have to hand it to you but I think it’s gonna be the way
– Stand Alone
yes vc will have to treat it p display p user(03/02/1992) and treat when inserting in the bank(1992-02-03)... in these formats
– Schielke