From e946079728e29b5873bd135359a45a3b2f3808c0 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Wed, 10 Jul 2024 12:44:18 +0300 Subject: [PATCH] modal check validate --- components/modal.vue | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/components/modal.vue b/components/modal.vue index fab00a0..b0c8c20 100644 --- a/components/modal.vue +++ b/components/modal.vue @@ -30,12 +30,15 @@ type modalDataType = { phone?: string name?: string email?: string + policy: boolean } const modal_data = reactive({ email: undefined, phone: undefined, - name: undefined + name: undefined, + policy: true }) + const modal_form = reactive({ disabled: true, errors: [], @@ -62,13 +65,17 @@ const validate = () => { modal_form.disabled = true if ( - (modal_data.phone && phone_regexp.test(modal_data.phone)) - || (modal_data.email && email_regex.test(modal_data.email)) + ( + (modal_data.phone && phone_regexp.test(modal_data.phone)) + || (modal_data.email && email_regex.test(modal_data.email)) + ) && modal_data.policy == true ) { modal_form.disabled = false return } } +watch(modal_data, validate) + const submit = async (e: any) => { goal('submit_form', modal_data) modal_state.show_status = 'loading' @@ -202,15 +209,15 @@ const policy = () => {