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
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'),
]"
:rules="
readonly
? undefined
: [
(v: string) =>
!v ||
/^[\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,12 +268,16 @@ 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'),
]"
:rules="
readonly
? undefined
: [
(v: string) =>
!v ||
/^[\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,12 +31,16 @@ 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'),
]"
:rules="
readonly
? undefined
: [
(v: string) =>
!v ||
/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(v) ||
$t('form.error.invalid'),
]
"
v-model="mail"
/>
<q-input