Skip to content
Snippets Groups Projects
Commit dfd056ec authored by Jens Christian Aanestad's avatar Jens Christian Aanestad
Browse files

refactor/fixed password validation

parent c734349a
No related branches found
No related tags found
1 merge request!23refactor/fixed password validation
Pipeline #274893 failed
...@@ -29,6 +29,10 @@ const props = defineProps({ ...@@ -29,6 +29,10 @@ const props = defineProps({
min: { min: {
type: String, type: String,
required: false required: false
},
pattern: {
type: String,
default: null
} }
}); });
...@@ -47,6 +51,7 @@ const onInputEvent = (event: any) => { ...@@ -47,6 +51,7 @@ const onInputEvent = (event: any) => {
:placeholder="props.placeholder" :placeholder="props.placeholder"
:id="inputId" required :id="inputId" required
:min="min" :min="min"
:pattern="pattern"
/> />
<div v-if="props.isValid" class="invalid-feedback">Invalid {{ label }}</div> <div v-if="props.isValid" class="invalid-feedback">Invalid {{ label }}</div>
<div v-else class="valid-feedback">Valid {{ label }}</div> <div v-else class="valid-feedback">Valid {{ label }}</div>
......
...@@ -62,7 +62,7 @@ const handleSubmit = async () => { ...@@ -62,7 +62,7 @@ const handleSubmit = async () => {
<form ref="formRef" id="loginForm" @submit.prevent="handleSubmit" novalidate> <form ref="formRef" id="loginForm" @submit.prevent="handleSubmit" novalidate>
<BaseInput :model-value="emailRef" @input-change-event="handleEmailInputEvent" id="emailInput" input-id="email" <BaseInput :model-value="emailRef" @input-change-event="handleEmailInputEvent" id="emailInput" input-id="email"
type="email" label="Email" placeholder="Enter your email" /> type="email" label="Email" placeholder="Enter your email" />
<BaseInput :model-value="passwordRef" @input-change-event="handlePasswordInputEvent" id="passwordInput" <BaseInput pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,16}" :model-value="passwordRef" @input-change-event="handlePasswordInputEvent" id="passwordInput"
input-id="password" type="password" label="Password" placeholder="Enter password" /> input-id="password" type="password" label="Password" placeholder="Enter password" />
<p class="text-danger">{{ errorMsg }}</p> <p class="text-danger">{{ errorMsg }}</p>
<button1 id="confirmButton" type="submit" @click="handleSubmit" button-text="Login"></button1> <button1 id="confirmButton" type="submit" @click="handleSubmit" button-text="Login"></button1>
......
...@@ -33,6 +33,14 @@ const handleConfirmPasswordInputEvent = (newValue: any) => { ...@@ -33,6 +33,14 @@ const handleConfirmPasswordInputEvent = (newValue: any) => {
} }
const handleSubmit = () => { const handleSubmit = () => {
const form = formRef.value;
// Check if the form is valid
if (form.checkValidity()) {
// Form is valid, submit the form or perform other actions
console.log('Form is valid');
}
formRef.value.classList.add("was-validated") formRef.value.classList.add("was-validated")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment