Created
March 10, 2019 09:20
-
-
Save DevCodo/7aedf91ce09b5800c9448068c0b23ae8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function setSelectionRange(input, selectionStart, selectionEnd) { // функция для постановки курсора | |
| if (input.setSelectionRange) { | |
| input.focus(); | |
| input.setSelectionRange(selectionStart, selectionEnd); | |
| } | |
| else if (input.createTextRange) { | |
| var range = input.createTextRange(); | |
| range.collapse(true); | |
| range.moveEnd('character', selectionEnd); | |
| range.moveStart('character', selectionStart); | |
| range.select(); | |
| } | |
| } | |
| $(".tel").each(function() { // маска для ввода телефона через плагин jquery.maskedinput | |
| $(this).mask("+7(999) 999-9999"); | |
| $(this).on("click", function() { | |
| setSelectionRange(this, 3, 3) | |
| }) | |
| $(this).on("keyup", function() { | |
| if ( $(this).val() == "+7(8__) ___-____" ) { | |
| var e = $.Event("keydown", { keyCode: 8}); | |
| $(this).trigger(e); | |
| } | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment