From c015bea5c17a4587752d391e0aff573c4b28b02e Mon Sep 17 00:00:00 2001 From: Craig Laparo Date: Mon, 4 Dec 2023 15:31:08 -0600 Subject: [PATCH] Keep regex in memory --- src/components/Search.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Search.vue b/src/components/Search.vue index dea91bc..964a9c7 100644 --- a/src/components/Search.vue +++ b/src/components/Search.vue @@ -43,16 +43,15 @@ function sendFormData () { emit('searchEvent', formData.value) } - + + const IDFieldRegex = /^(?!.*,,)(?!.*--)\d+([-,\d]*\d+)?$/; function validateIDField(id: string): boolean { resetFormValidation(); if(!id) { return true; } - const regex = /^(?!.*,,)(?!.*--)\d+([-,\d]*\d+)?$/; - - if (!regex.test(id)) { + if (!IDFieldRegex.test(id)) { setFormValidation('Invalid ID format (e.g. 123 | 123-456 | 123,456,789)'); return false; }