When I paste the text 00005127120 into the input, it should displays 000.051.271-20, but is showing 005.127.120. If I paste 00245127120 it shows 245.127.120.
You can reproduce it here: https://codepen.io/egoncalves/pen/MRKymb
step-by-step instructions for reproducing the issue:
All browsers
Hi @cvializ
As amp-inputmask uses RobinHerbots' Inputmask (release 4.0.4), I tested it with same version, and it's working.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input id="cpf" name="cpf"/>
<br/>
<script src="https://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="https://rawgit.com/RobinHerbots/Inputmask/4.0.4/dist/jquery.inputmask.bundle.js"></script>
<script>
$("#cpf").inputmask("999.999.999-99");
</script>
</body>
</html>
Thanks for sharing your experience and for the detailed example! I am able to reproduce and I found the root cause. I'll prioritize it for work soon
After investigating, I found that the custom mask in amp-inputmask was over-optimized for the telephone number use case. I propose we add a mask-strip-zeros attribute to allow document authors to opt-in to removing the zeros. This is not backward compatible, but usage is still low and the behavior only applies on paste which is not a critical flow that people will be depending on to remain the same. This will avoid surprising future users and document authors.
Most helpful comment
After investigating, I found that the custom mask in
amp-inputmaskwas over-optimized for the telephone number use case. I propose we add amask-strip-zerosattribute to allow document authors to opt-in to removing the zeros. This is not backward compatible, but usage is still low and the behavior only applies on paste which is not a critical flow that people will be depending on to remain the same. This will avoid surprising future users and document authors.