PageSourceSearch

https://mi.by/local/components/mi/authorization/templates/mi_register/script.js?17381248072567

js mi.by collected 2026-10-04 02:39:43 UTC 2,567 bytes, 80 lines download raw bytes

1$(document).ready(function() {
2    const form = $('#modal-register')
3    const email = $('#input-register-1')
4    const password = $('#input-register-2')
5    const passwordConfirm = $('#input-register-3')
6    const userAccept = $('#input-register-4')
7    email.blur(function () {
8        if($(this).val() && !isEmail($(this).val())) {
9            $(this).addClass("error")
10        }
11    })
12
13    userAccept.on('change', function() {
14        if($(this).is(':checked')){
15            form.find('[type="submit"]').attr('disabled', false);
16        }else{
17            form.find('[type="submit"]').attr('disabled', true);
18        }
19    });
20
21    email.on("input", function () {
22        $(this).removeClass("error")
23    })
24
25    const passwordEvents = ["input", "focus"]
26    passwordEvents.forEach(event => {
27        passwordConfirm.on(event, function () {
28            areEqual(passwordConfirm, password)
29        })
30    })
31
32    form.submit(function () {
33        if (!areEqual(password, passwordConfirm)) {
34            return false
35        }
36
37        BX.ajax.runComponentAction('mi:authorization', 'register', {
38            data: {
39                email: email.val(),
40                password: password.val(),
41                password_confirm: passwordConfirm.val()
42            }
43        }).then(function (response) {
44            //location.reload()
45            $("#register").hide();
46            $("#register-thanks").addClass('modal--open');
47        }, function (response) {
48            response.errors.forEach(error => {
49                switch (error.code) {
50                    case 'LOGIN_ERROR':
51                        case 'OTHER_ERROR':
52                            email.addClass('error')
53                            email.siblings('span').html(error.message.replace('логином', 'e-mail'))
54                            break
55                    case 'PASSWORD_ERROR':
56                        password.addClass('error')
57                        password.siblings('span').html(error.message)
58                        break
59                }
60            })
61        });
62        return false
63    })
64})
65
66function isEmail(email) {
67    const pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
68    return pattern.test(email)
69}
70
71function areEqual(input1, input2) {
72    if (input2.val().length > 0 && input1.val() !== input2.val()) {
73        input1.addClass("error")
74        return false
75    } else {
76        input1.removeClass("error")
77        return true
78    }
79}
80

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.