diff --git a/addons/default/visiosoft/base-theme/resources/css/register.css b/addons/default/visiosoft/base-theme/resources/css/register.css index cbfd641bd..954390e8e 100644 --- a/addons/default/visiosoft/base-theme/resources/css/register.css +++ b/addons/default/visiosoft/base-theme/resources/css/register.css @@ -11,4 +11,19 @@ .personal-advantages img { max-height: 60px; max-width: 60px; +} + +.approved-phone { + background-color: #ebf2e5 !important; + border-color: #4a7c20 !important; +} + +.rejected-phone { + background-color: #f8e6e9 !important; + border-color: #ba7b84 !important; +} + +.phone-validation-error { + color: #c75050; + font-size: 14px; } \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/js/register.js b/addons/default/visiosoft/base-theme/resources/js/register.js index b5b0d5572..5930e77f5 100644 --- a/addons/default/visiosoft/base-theme/resources/js/register.js +++ b/addons/default/visiosoft/base-theme/resources/js/register.js @@ -1 +1,48 @@ phoneMask("input[name='phone'],input[name='land_phone']"); + +// Phone register validation +//setup before functions +let typingTimer; +let doneTypingInterval = 650; +let phoneInput = $(".validate-phone input[name='phone']"); + +//on keyup, start the countdown +phoneInput.on('keyup', function () { + clearTimeout(typingTimer); + typingTimer = setTimeout(function () { + doneTyping(phoneInput.val()) + }, doneTypingInterval) +}); + +//on keydown, clear the countdown +phoneInput.on('keydown', function () { + clearTimeout(typingTimer); +}); + +function doneTyping(phoneNum) { + if (!phoneNum.includes('_') && phoneNum !== "") { + let countryCode = $(".iti__selected-flag").attr('title').split("+"); + countryCode = '+' + countryCode[countryCode.length - 1]; + + $.ajax({ + type: 'GET', + data: {'phoneNumber': countryCode + phoneNum.substr(1)}, + url: 'ajax/phone-validation', + success: function (response) { + if (response.userExists) { + phoneInput.addClass('rejected-phone'); + phoneInput.removeClass('approved-phone'); + $('.phone-validation-error').removeClass('d-none') + } else { + phoneInput.addClass('approved-phone'); + phoneInput.removeClass('rejected-phone'); + $('.phone-validation-error').addClass('d-none') + } + }, + }); + } else { + phoneInput.removeClass('approved-phone'); + phoneInput.removeClass('rejected-phone'); + $('.phone-validation-error').addClass('d-none') + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/lang/en/field.php b/addons/default/visiosoft/base-theme/resources/lang/en/field.php index 4ff406659..9677f96b6 100644 --- a/addons/default/visiosoft/base-theme/resources/lang/en/field.php +++ b/addons/default/visiosoft/base-theme/resources/lang/en/field.php @@ -31,6 +31,9 @@ return [ 'personal_registration_list_3' => 'Send messages to the ad owners on the site.', 'register_information_note' => 'The information on this page is taken for ' . env('APPLICATION_DOMAIN') . ' membership. You can find detailed information about the protection of personal data here.', + // Register page + 'phone_validation_error' => 'This email address is in use by another member.', + // Forgot Password 'create_new_password' => 'Create New Password', ]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig b/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig index 697f139be..c63a55cb9 100644 --- a/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig +++ b/addons/default/visiosoft/base-theme/resources/views/addons/anomaly/users-module/partials/register-form.twig @@ -47,6 +47,25 @@ 'class' :'hidden', }).input|raw }} {% endif %} +
+ + {{ trans('visiosoft.theme.base::field.phone_validation_error') }} +
+