From 58e25b77597a266265e3b6b6e10ac00d4e588975 Mon Sep 17 00:00:00 2001 From: "p.belezov" Date: Tue, 29 Oct 2024 14:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B3=D1=83=D0=BB=D1=8F=D1=80=D0=BA=D1=83=20=D0=B2=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=20=D1=81=20=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/rules.js | 3 +++ resources/views/Wishlist/CreateWish.vue | 2 +- resources/views/Wishlist/EditWish.vue | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/js/rules.js b/resources/js/rules.js index 12d5fd1..1b0d344 100644 --- a/resources/js/rules.js +++ b/resources/js/rules.js @@ -11,5 +11,8 @@ export const rules = { }, price: value => { return (typeof value == 'number' || typeof value == 'undefined' || value === null) || 'Стоимость должна быть числом'; + }, + isNumber: value => { + return /^\d+[\.,\,]?\d*$/.test(value); } } diff --git a/resources/views/Wishlist/CreateWish.vue b/resources/views/Wishlist/CreateWish.vue index 9f4e2f9..0fe49e9 100644 --- a/resources/views/Wishlist/CreateWish.vue +++ b/resources/views/Wishlist/CreateWish.vue @@ -27,7 +27,7 @@ export default { if (this.price == ''){ this.price = null; } - if (typeof this.price == 'string' && /^\d+[\.,\,]?\d*$/.test(this.price)){ + if (typeof this.price == 'string' && rules.isNumber(this.price)){ this.price = parseFloat(this.price) } let validateName = rules.notNull(this.name); diff --git a/resources/views/Wishlist/EditWish.vue b/resources/views/Wishlist/EditWish.vue index 202bd1f..2f930e8 100644 --- a/resources/views/Wishlist/EditWish.vue +++ b/resources/views/Wishlist/EditWish.vue @@ -35,7 +35,7 @@ export default { if (this.price == ""){ this.price = null; } - if (typeof this.price == 'string' && /^\d+[\.,\,]?\d*$/.test(this.price)){ + if (typeof this.price == 'string' && rules.isNumber(this.price)){ this.price = parseFloat(this.price) } let validateId = rules.id(this.wish_id);