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
# Phone Mask | |
# маска телефонного номера для input | |
# IE9+ | |
# -------------------------------------------------------- | |
# cache | |
# phones — массив input-элементов, которым нужна маска | |
# setCaret — устанавливает курсор в нужную позицию | |
# getCaret — получает значение курсора | |
# mask — функция маскировки | |
# nums — массив из введенных чисел и _ (без семерки) |
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 doGetCaretPosition (ctrl) { | |
var CaretPos = 0; // IE Support | |
if (document.selection) { | |
ctrl.focus (); | |
var Sel = document.selection.createRange (); | |
Sel.moveStart ('character', -ctrl.value.length); | |
CaretPos = Sel.text.length; | |
} | |
// Firefox support | |
else if (ctrl.selectionStart || ctrl.selectionStart == '0') |
NewerOlder