igorescobar / jQuery-Mask-Plugin

A jQuery Plugin to make masks on form fields and HTML elements.
http://igorescobar.github.io/jQuery-Mask-Plugin/
Other
4.77k stars 1.42k forks source link

using in contenteditable elements, odd behavior #685

Open rogerpec opened 6 years ago

rogerpec commented 6 years ago

Hello.

Thank you Igor Escobar and contributors by this very usefull plugin.

I'm trying to use the plugin in some contenteditable elements such as divs and spans. But the behavior is being odd. When the typing reachs a symbol, the caret goes to start of element, even with no reverse option.

Here is a fiddle to check: https://jsfiddle.net/k6bc7v1z/9/

When typed 12-34 (typing the -), the result is 12-34, ok. When typed 1234, the result is 41-23

What I´m doing wrong? I read the issues and docs, but can't found solution.

Thanks in advance

dpmango commented 5 years ago

Facing the same behavior

With mask like $("[js-cta-phone]").mask("000 000-00-00");

when key pressed on the position of space or character "-" cursor jumps to the beginning (4th keyup). So 5th key will add user input at very beginning

rocooliveira commented 5 years ago

I am also having this problem and I find no solution. It's been 1 year since this post was made, did you guys achieve something satisfactory?

dpmango commented 4 years ago

No solution yet. The only option is not to use contenteditable (just regular input) for now

Also relevant issue

707

dpmango commented 3 years ago

Hey there! Planning on reopening issues? Ready to test if it still occurring unexpected behavior...