PageSourceSearch

https://expert-park.su/local/templates/ro_expertpark/assets/js-standalone/modules/init-mask.js

js expert-park.su collected 2026-10-07 18:04:36 UTC 2,025 bytes, 88 lines download raw bytes

1const initMask = () => {
2  // Requires IMask to be loaded globally via CDN
3  if (!window.IMask) {
4    console.warn('IMask library is not loaded')
5    return
6  }
7
8  const inputsTel = document.querySelectorAll('.js-tel')
9  const inputsMail = document.querySelectorAll('.js-mail')
10  const inputsDate = document.querySelectorAll('.js-date')
11  const inputsName = document.querySelectorAll('.js-name')
12
13  inputsTel.forEach((input) => {
14    const form = input.closest('form')
15    const telMask = new window.IMask(input, {
16      mask: '+{7} (000) 000-00-00'
17    })
18    const initialValue = telMask.value
19
20    if (form) {
21      form.addEventListener('reset', () => {
22        setTimeout(() => (input.value = initialValue), 0)
23      })
24    }
25
26    return telMask
27  })
28
29  inputsMail.forEach((input) => {
30    const mainMask = new window.IMask(input, {
31      mask: (value) => {
32        if (/^[a-z0-9_.-]+$/.test(value)) {
33          return true
34        }
35
36        const parts = value.split('@')
37        if (parts.length === 1) {
38          return /^[a-z0-9_.-]*$/.test(parts[0])
39        } else if (parts.length === 2) {
40          return /^[a-z0-9_.-]*$/.test(parts[0]) && /^[a-z0-9.-]*$/.test(parts[1])
41        }
42        return false
43      },
44      lazy: false
45    })
46
47    return mainMask
48  })
49
50  inputsDate.forEach((input) => {
51    const dateMask = new window.IMask(input, {
52      mask: 'DD.MM.YYYY',
53      blocks: {
54        DD: {
55          mask: window.IMask.MaskedRange,
56          from: 1,
57          to: 31,
58          maxLength: 2
59        },
60        MM: {
61          mask: window.IMask.MaskedRange,
62          from: 1,
63          to: 12,
64          maxLength: 2
65        },
66        YYYY: {
67          mask: window.IMask.MaskedRange,
68          from: 1900,
69          to: 2099,
70          maxLength: 4
71        }
72      }
73    })
74
75    return dateMask
76  })
77
78  inputsName.forEach((input) => {
79    const nameMask = new window.IMask(input, {
80      mask: /^[а-яё\s\-]*$/i,
81      lazy: false
82    })
83
84    return nameMask
85  })
86}
87
88window.initMask = initMask

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.