Commit 5d86ded8 authored by Irina Oleynik's avatar Irina Oleynik

Скрипт на текстовое поле с маской "_ мес."

parent 382d145e
if (!model.EVENT_valueChange) {
model.on('valueChange', () => {
let textboxPassportNumberZ = model.playerModel.getModelWithId('textbox_passport_number_z'); //поменять на нужный textbox
if (textboxPassportNumberZ) {
let inputValue = textboxPassportNumberZ.getValue();
let textboxPassportNumberZ = model.playerModel.getModelWithId('textbox_passport_number_z'); //поменять на нужный textbox
if (textboxPassportNumberZ) {
textboxPassportNumberZ.setValue('мес.');
model.on('valueChange', () => {
let inputValue = textboxPassportNumberZ.getValue().replace(/\s*мес\.$/, '');
let numberOnly = inputValue.replace(/\D/g, '');
if (numberOnly) {
textboxPassportNumberZ.setValue(`${numberOnly} мес.`);
});
document.addEventListener('keydown', (event) => {
if (event.key === 'Backspace') {
let inputValue = textboxPassportNumberZ.getValue().replace(/\s*мес\.$/, '');
let numberOnly = inputValue.slice(0, -1);
textboxPassportNumberZ.setValue(`${numberOnly} мес.`);
event.preventDefault();
}
} else {
console.error('Поле "textbox_passport_number_z" не найдено.');
}
});
});
} else {
console.error('Поле "textbox_passport_number_z" не найдено.');
}
model.EVENT_valueChange = true;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment