The problem with the virtual button Backspace, as it removes not only the number but also the mask that sets the format for the number. Who faced this tell me how you can solve this problem?

Here is the button script:

function del(){ var str = document.getElementById('phone').value; parseInt(str) document.getElementById('phone').value = str.substring(0, str.length-1); console.log(str) } 

here is the button layout:

 <input type="button" class="mybutton" onclick="del()" data-paste="→" value="→"/> 

Here is the full code: https://jsfiddle.net/0xL0fctq/98/

    1 answer 1

    When you use a mask (by the way, you did not specify the script itself, so I use my telepathic abilities), the script replaces the contents of the input in the html-string with the given mask formatting rules.

    What can be done:

    1) Look at the mask script, does it have any functions like setValue that bypasses the mask markup?

    or

    2) Before pressing this button, call the destroy () mask of the script (or whatever is there, telepathy does not help here) on this input, change the value, and then "create" again.