You've already forked isop-mirror
feat: enhance phone input validation in registration form
This commit is contained in:
@@ -19,7 +19,8 @@ useSeoMeta({
|
|||||||
const rules = {
|
const rules = {
|
||||||
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
required: (v: any) => (!!v && String(v).trim().length > 0) || 'Povinné pole',
|
||||||
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
|
email: (v: string) => /.+@.+\..+/.test(v) || 'Zadajte platný email',
|
||||||
phone: (v: string) => (!v || /^[0-9 +()-]{6,}$/.test(v)) || 'Zadajte platné telefónne číslo',
|
phone: (v: string) =>
|
||||||
|
(!v || /^\+[0-9]{6,13}$/.test(v)) || 'Zadajte platné telefónne číslo. Príklad: +421908123456',
|
||||||
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
|
mustAgree: (v: boolean) => v === true || 'Je potrebné súhlasiť',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,8 +102,8 @@ async function handleRegistration() {
|
|||||||
density="comfortable" />
|
density="comfortable" />
|
||||||
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
<v-text-field v-model="form.email" :rules="[rules.required, rules.email]" label="Email:"
|
||||||
variant="outlined" density="comfortable" />
|
variant="outlined" density="comfortable" />
|
||||||
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón:" variant="outlined"
|
<v-text-field v-model="form.phone" :rules="[rules.phone]" label="Telefón (s predvoľbou):"
|
||||||
density="comfortable" />
|
variant="outlined" density="comfortable" />
|
||||||
|
|
||||||
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
|
<v-checkbox v-model="form.consent" :rules="[rules.mustAgree]"
|
||||||
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
label="Súhlasím s podmienkami spracúvania osobných údajov" density="comfortable" />
|
||||||
|
|||||||
Reference in New Issue
Block a user