feat: validate email

This commit is contained in:
Methapon Metanipat 2024-09-05 15:50:51 +07:00
parent d6e8d754ab
commit 9466019303
3 changed files with 18 additions and 0 deletions

View file

@ -38,6 +38,12 @@ defineProps<{
hide-bottom-space
class="col-12 col-md-4"
:label="$t('form.email')"
:rules="[
(v: string) => !!v || $t('form.error.required'),
(v: string) =>
/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) ||
$t('form.error.invalid'),
]"
for="input-email"
:model-value="readonly ? email || '-' : email"
@update:model-value="(v) => (typeof v === 'string' ? (email = v) : '')"

View file

@ -268,6 +268,12 @@ watch(
outlined
:readonly="readonly"
:label="$t('form.email')"
:rules="[
(v: string) => !!v || $t('form.error.required'),
(v: string) =>
/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) ||
$t('form.error.invalid'),
]"
class="col-md-3 col-6"
:model-value="readonly ? email || '-' : email"
@update:model-value="(v) => (typeof v === 'string' ? (email = v) : '')"

View file

@ -31,6 +31,12 @@ const telephone = defineModel<string>('telephone');
hide-bottom-space
class="col-md-6 col-12"
:label="$t('form.email')"
:rules="[
(v: string) => !!v || $t('form.error.required'),
(v: string) =>
/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) ||
$t('form.error.invalid'),
]"
v-model="mail"
/>
<q-input