Files
zbiorki_app/static/js/dodaj_zbiorke.js
Mateusz Gruszczyński e9db945bb4 przebudowa systemu
2025-08-28 10:27:06 +02:00

37 lines
1.3 KiB
JavaScript

(function () {
const opis = document.getElementById('opis');
const opisCount = document.getElementById('opisCount');
if (opis && opisCount) {
const updateCount = () => opisCount.textContent = opis.value.length.toString();
opis.addEventListener('input', updateCount);
updateCount();
}
const iban = document.getElementById('numer_konta');
if (iban) {
iban.addEventListener('input', () => {
const digits = iban.value.replace(/\D/g, '').slice(0, 26);
const chunked = digits.replace(/(.{4})/g, '$1 ').trim();
iban.value = chunked;
});
}
const tel = document.getElementById('numer_telefonu_blik');
if (tel) {
tel.addEventListener('input', () => {
const digits = tel.value.replace(/\D/g, '').slice(0, 9);
const parts = [];
if (digits.length > 0) parts.push(digits.substring(0, 3));
if (digits.length > 3) parts.push(digits.substring(3, 6));
if (digits.length > 6) parts.push(digits.substring(6, 9));
tel.value = parts.join(' ');
});
}
const cel = document.getElementById('cel');
if (cel) {
cel.addEventListener('change', () => {
if (cel.value && Number(cel.value) < 0.01) cel.value = '0.01';
});
}
})();