There is input to which the user enters a phone number:
<input autofocus="autofocus" type="tel" name="phone" id="phone_number"/> Used jQuery Masked Input Plugin Version: 1.4.1
input has a mask +7(___)___-__-__
if (!$.browser.msie && !parseInt($.browser.version)<7) {$('#phone_number').mask("+7(999)999-99-99");} If the user has moved the cursor in the middle of the mask, then it is difficult for him to enter a phone number (especially if he is watching the site on the smartphone).
For example, he accidentally moved the cursor +7(___)___-袣校袪小袨袪 __-__ Then, when he begins to enter a number, it will turn out to enter only 4 digits. +7(___)___-98-76 . And then you can not enter.
There are two different ideas:
Somehow prohibit to put the cursor so that to the left of the cursor were empty (unfilled) characters. Then in the example above: If the user wants to put the cursor in the center
+7(___)___-袣校袪小袨袪 __-__then he automatically moves to the left:+7(袣校袪小袨袪 ___)___- __-__Somehow to implement: If the user has placed the cursor in the center
+7(___)___-袣校袪小袨袪 __-__and began to enter a phone number, then the input is as follows:
+7(___)___-袣校袪小袨袪 __-__ +7(___)___-9_-__ +7(___)___-98-__ +7(___)___-98-7_ +7(___)___-98-76 +7(___)__9-87-65 +7(___)_98-76-54 +7(___)987-65-43 +7(__9)876-54-32 +7(_98)765-43-21 +7(987)654-32-10 How to implement these options?