Fix: поле Цена сохраняет ввод с клавиатуры (убрано форматирование в input type=number)

Made-with: Cursor
This commit is contained in:
2026-02-26 12:34:58 +00:00
parent b0649c997f
commit 7673a12027
3 changed files with 12 additions and 44 deletions

View File

@@ -124,27 +124,12 @@
form.addEventListener('input', updateRowAmounts);
form.querySelectorAll('#order-items input[name$="-price"]').forEach(function(input) {
input.addEventListener('blur', function() {
var v = parseNum(this.value);
if (!isNaN(v) && this.value.trim() !== '') this.value = formatNum(v).replace(',', '.');
});
input.addEventListener('focus', function() {
this.value = String(this.value).replace(/\s/g, '').replace(',', '.');
});
});
form.addEventListener('submit', function() {
form.querySelectorAll('input[name$="-price"]').forEach(function(input) {
input.value = String(input.value).replace(/\s/g, '').replace(',', '.');
});
});
document.querySelectorAll('#order-items input[name$="-price"]').forEach(function(input) {
if (input.value && input.value.trim() !== '') {
var v = parseNum(input.value);
input.value = formatNum(v).replace(',', '.');
}
});
updateRowAmounts();
document.getElementById('add-order-row').addEventListener('click', function() {
@@ -170,13 +155,6 @@
});
var amountCell = clone.querySelector('.row-amount');
if (amountCell) amountCell.textContent = '—';
clone.querySelector('input[name$="-price"]')?.addEventListener('blur', function() {
var v = parseNum(this.value);
if (!isNaN(v) && this.value.trim() !== '') this.value = formatNum(v).replace(',', '.');
});
clone.querySelector('input[name$="-price"]')?.addEventListener('focus', function() {
this.value = String(this.value).replace(/\s/g, '').replace(',', '.');
});
tbody.appendChild(clone);
totalInput.value = nextIndex + 1;
});

View File

@@ -130,27 +130,12 @@
form.addEventListener('input', updateRowAmounts);
form.querySelectorAll('#supplier-order-items input[name$="-price"]').forEach(function(input) {
input.addEventListener('blur', function() {
var v = parseNum(this.value);
if (!isNaN(v) && this.value.trim() !== '') this.value = formatNum(v).replace(',', '.');
});
input.addEventListener('focus', function() {
this.value = String(this.value).replace(/\s/g, '').replace(',', '.');
});
});
form.addEventListener('submit', function() {
form.querySelectorAll('input[name$="-price"]').forEach(function(input) {
input.value = String(input.value).replace(/\s/g, '').replace(',', '.');
});
});
document.querySelectorAll('#supplier-order-items input[name$="-price"]').forEach(function(input) {
if (input.value && input.value.trim() !== '') {
var v = parseNum(input.value);
input.value = formatNum(v).replace(',', '.');
}
});
updateRowAmounts();
document.getElementById('add-supplier-order-row').addEventListener('click', function() {
@@ -176,13 +161,6 @@
});
var amountCell = clone.querySelector('.row-amount');
if (amountCell) amountCell.textContent = '—';
clone.querySelector('input[name$="-price"]')?.addEventListener('blur', function() {
var v = parseNum(this.value);
if (!isNaN(v) && this.value.trim() !== '') this.value = formatNum(v).replace(',', '.');
});
clone.querySelector('input[name$="-price"]')?.addEventListener('focus', function() {
this.value = String(this.value).replace(/\s/g, '').replace(',', '.');
});
tbody.appendChild(clone);
totalInput.value = nextIndex + 1;
});