From cfa3c2091dfcada4500b07afb21fbb3e86e99db6 Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Fri, 2 Jul 2021 16:42:15 +0300 Subject: [PATCH] Refactor function --- resources/assets/js/views/common/items.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/views/common/items.js b/resources/assets/js/views/common/items.js index bedf1cf25..25b8e9c93 100644 --- a/resources/assets/js/views/common/items.js +++ b/resources/assets/js/views/common/items.js @@ -55,16 +55,15 @@ const app = new Vue({ }, 'form.purchase_price': function (newVal, oldVal) { - if (newVal != '' && newVal.search('^(?=.*?[0-9])[0-9.,]+$') == -1) { + if (newVal != '' && newVal.search('^(?=.*?[0-9])[0-9.,]+$') !== 0) { this.form.purchase_price = oldVal; + return; } - - if (newVal.search('^(?=.*?[0-9])[0-9.,]+$') == 0) { - for (let item of this.regex_condition) { - if (this.form.purchase_price.includes(item)) { - this.splice_value = this.form.purchase_price.replace(item, ''); - this.form.purchase_price = this.splice_value; - } + + for (let item of this.regex_condition) { + if (this.form.purchase_price.includes(item)) { + this.splice_value = this.form.purchase_price.replace(item, ''); + this.form.purchase_price = this.splice_value; } } }