Skip to content
Snippets Groups Projects
Commit cab31c1b authored by Anders Høvik's avatar Anders Høvik
Browse files

adjusted form for BaseInput

parent 684263c2
No related branches found
No related tags found
1 merge request!30Feature/update user settings layout
...@@ -8,6 +8,7 @@ const emailRef = ref('') ...@@ -8,6 +8,7 @@ const emailRef = ref('')
const passwordRef = ref('') const passwordRef = ref('')
const confirmPasswordRef = ref('') const confirmPasswordRef = ref('')
const formRef = ref() const formRef = ref()
let samePasswords = ref(true)
const handleFirstNameInputEvent = (newValue: any) => { const handleFirstNameInputEvent = (newValue: any) => {
firstNameRef.value = newValue firstNameRef.value = newValue
...@@ -30,18 +31,27 @@ const handleConfirmPasswordInputEvent = (newValue: any) => { ...@@ -30,18 +31,27 @@ const handleConfirmPasswordInputEvent = (newValue: any) => {
confirmPasswordRef.value = newValue confirmPasswordRef.value = newValue
} }
const handleSubmit = () => { const handleSubmit = async () => {
console.log(firstNameRef.value)
samePasswords.value = (passwordRef.value === confirmPasswordRef.value)
console.log(samePasswords.value)
const form = formRef.value; const form = formRef.value;
// Check if the form is valid // Check if the form is valid
if (form.checkValidity()) { if (form.checkValidity()) {
// Form is valid, submit the form or perform other actions // Form is valid, submit the form or perform other actions
console.log('Form is valid'); console.log('Form is valid');
} else {
console.log('Form is not valid');
} }
formRef.value.classList.add("was-validated") formRef.value.classList.add("was-validated")
} }
</script> </script>
<template> <template>
...@@ -49,76 +59,84 @@ const handleSubmit = () => { ...@@ -49,76 +59,84 @@ const handleSubmit = () => {
<!-- The userprofile and the form that will update name, email, password --> <!-- The userprofile and the form that will update name, email, password -->
<div class="row"> <div class="row">
<div class="col-md-2 text-center"> <div class="col-md-2 text-center">
<img src="/src/assets/userprofile.png" class="img-fluid"> <img src="/src/assets/userprofile.png" class="img-fluid" alt="userprofile">
<p class="h2">Username</p> <p class="h2">Username</p>
</div> </div>
<div class="col-md-10"> <div class="col-md-10">
<form class="needs-validation" novalidate> <form @submit.prevent="handleSubmit">
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<!-- <label for="inputFirstName" class="form-label">First Name</label>
<input type="text" class="form-control" id="inputFirstName" placeholder="ex: Brian">-->
<BaseInput :model-value="firstNameRef.value" <BaseInput :model-value="firstNameRef.value"
@input-change-event="handleFirstNameInputEvent" @input-change-event="handleFirstNameInputEvent"
ref="firstNameRef" ref="firstNameRef"
id="firstNameInput" id="firstNameInput-change"
input-id="first-name" input-id="first-name"
type="text" type="text"
label="First name" label="First name"
placeholder="Enter your first name"/> placeholder="Enter your first name"
<label for="inputFirstName" class="form-label">First Name</label> invalid-message="Please enter your first name"/>
<input type="text" class="form-control" id="inputFirstName" placeholder="ex: Brian">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<!-- <label for="inputPassword4">Last Name</label>
<input type="text" class="form-control" id="inputLastName" placeholder="ex: Cox">-->
<BaseInput :model-value="surnameRef.value" <BaseInput :model-value="surnameRef.value"
@input-change-event="handleSurnameInputEvent" @input-change-event="handleSurnameInputEvent"
ref="surnameRef" ref="surnameRef"
id="surnameInput" id="surnameInput-change"
input-id="surname" input-id="surname"
type="text" type="text"
label="Surname" label="Surname"
placeholder="Enter your surname"/> placeholder="Enter your surname"
<label for="inputPassword4">Last Name</label> invalid-message="Please enter your surname"/>
<input type="text" class="form-control" id="inputLastName" placeholder="ex: Cox">
</div> </div>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<!-- <label for="inputAddress">Email</label>
<input type="email" class="form-control" id="inputMail" placeholder="ex: briancox@mail.com">-->
<BaseInput :model-value="emailRef.value" <BaseInput :model-value="emailRef.value"
@input-change-event="handleEmailInputEvent" @input-change-event="handleEmailInputEvent"
ref="emailRef" ref="emailRef"
id="emailInput" id="emailInput-change"
input-id="email" input-id="email"
type="email" type="email"
label="Email" label="Email"
placeholder="Enter your email"/> placeholder="Enter your email"
<label for="inputAddress">Email</label> invalid-message="Invalid email"/>
<input type="email" class="form-control" id="inputMail" placeholder="ex: briancox@mail.com">
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<!-- <label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password with capital letter, number and a special character">-->
<BaseInput :model-value="passwordRef.value" <BaseInput :model-value="passwordRef.value"
@input-change-event="handlePasswordInputEvent" @input-change-event="handlePasswordInputEvent"
ref="passwordRef" ref="passwordRef"
id="passwordInput" id="passwordInput-change"
input-id="password" input-id="password"
type="password" type="password"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,16}"
label="Password" label="Password"
placeholder="Enter password"/> placeholder="Enter password"
<label for="inputEmail4">Password</label> invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"/>
<input type="password" class="form-control" id="inputPassword" placeholder="Password with capital letter, number and a special character">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<BaseInput :model-value="confirmPasswordRef.value" <!-- <label for="inputPasswordConfirmed">Confirmed Password</label>
<input type="password" class="form-control" id="inputPasswordConfirmed" placeholder="Repeat password">-->
<BaseInput :modelValue="confirmPasswordRef.value"
@input-change-event="handleConfirmPasswordInputEvent" @input-change-event="handleConfirmPasswordInputEvent"
ref="confirmPasswordRef" ref="confirmPasswordRef"
id="confirmPasswordInput" id="confirmPasswordInput-change"
input-id="confirmPassword" input-id="confirmPassword"
type="password" type="password"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,16}"
label="Confirm Password" label="Confirm Password"
placeholder="Confirm password"/> placeholder="Confirm password"
<label for="inputPassword4">Confirmed Password</label> invalid-message="Password must be between 4 and 16 characters and contain one capital letter, small letter and a number"/>
<input type="password" class="form-control" id="inputPasswordConfirmed" placeholder="Repeat password"> <p v-if="samePasswords" class="text-danger">The passwords are not identical</p>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Change settings</button> <button type="submit" @click="handleSubmit" class="btn btn-primary">Change settings</button>
</form> </form>
</div> </div>
</div> </div>
......
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