diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index f94c05ba1..bf0f3452c 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -811,15 +811,20 @@ const app = new Vue({ watch: { 'form.discount': function (newVal, oldVal) { - if (newVal != '' && newVal.search('^(?=.*?[0-9])[0-9.,]+$') !== 0) { + if (newVal > 99) { + newVal = oldVal; + return; + } + + if (newVal != '' && newVal.search('^[-+]?([0-9]|[1-9][0-9]|100)*\.?[0-9]+$') !== 0) { this.form.discount = oldVal; - this.form.discount = this.form.discount.replace(',', '.'); + this.form.discount = this.form.discount ? this.form.discount.replace(',', '.') : ''; return; } for (let item of this.regex_condition) { - if (this.form.discount.includes(item)) { + if (this.form.discount && this.form.discount.includes(item)) { const removeLastChar = newVal.length - 1; const inputShown = newVal.slice(0, removeLastChar); @@ -827,7 +832,7 @@ const app = new Vue({ } } - this.form.discount = this.form.discount.replace(',', '.'); + this.form.discount = this.form.discount ? this.form.discount.replace(',', '.') : ''; }, 'form.loading': function (newVal, oldVal) {