fix: email should not required and fix error on empty

This commit is contained in:
Methapon Metanipat 2024-09-05 16:35:51 +07:00
parent 6ec60cc95a
commit 51afed5578
3 changed files with 30 additions and 18 deletions

View file

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

View file

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

View file

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