debian-mirror-gitlab/app/assets/javascripts/pages/profiles/show/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
562 B
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import emojiRegex from 'emoji-regex';
2019-07-31 22:56:46 +05:30
import { __ } from '~/locale';
2022-10-11 01:57:18 +05:30
import { initSetStatusForm } from '~/profile/profile';
2018-11-18 11:00:15 +05:30
2022-10-11 01:57:18 +05:30
initSetStatusForm();
2018-11-18 11:00:15 +05:30
2021-04-29 21:17:54 +05:30
const userNameInput = document.getElementById('user_name');
2022-10-11 01:57:18 +05:30
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('');
}
});
}