Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « show « profiles « pages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96ea7329e6e1e1c79c832d9e0ba50a5c7bac6cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import emojiRegex from 'emoji-regex';
import { __ } from '~/locale';
import { initSetStatusForm } from '~/profile/profile';

initSetStatusForm();

const userNameInput = document.getElementById('user_name');
if (userNameInput) {
  userNameInput.addEventListener('input', () => {
    const EMOJI_REGEX = emojiRegex();
    if (EMOJI_REGEX.test(userNameInput.value)) {
      // set field to invalid so it gets detected by GlFieldErrors
      userNameInput.setCustomValidity(__('Invalid field'));
    } else {
      userNameInput.setCustomValidity('');
    }
  });
}