a form after validate must go to next author page with vue-Router using this code but not validate
<form @submit.prevent="handlesubmit">
<div class="row">
<div class="col-md-4 mb-3">
<label>Name</label>
<input type="search" class="form-control" placeholder="" v-model.lazy.trim="form.nameTitle">
<div class=" text-danger">
{{ form.titleNameErrorText }}
</div>
</div>
<div class="row mt-4">
<div class="col-6 ">
<button class="btn btn-primary btn-style" type="submit" >Submit
</button>
</div>
</div>
</form>
js code and vue router handle next page after validation
> import { reactive } from "vue";
import { useRoute, useRouter } from 'vue-router'
export default {
setup() {
const router = useRouter();
const form = reactive({
nameTitle: "",
familyTitle: "",
addressTitle: "",
phoneNumber: "",
titleNameErrorText: "",
titleFamilyErrorText: "",
titleAddressErrorText: "",
titlePhoneErrorText: "",
name: "FormAddress",
});
function validate() {
if (form.nameTitle.length < 3) {
form.titleNameErrorText = "نام حداقل باید دارای 3 حرف باشد "
}
else {
form.titleNameErrorText = ""
}
if (form.familyTitle.length < 3) {
form.titleFamilyErrorText = "نام خانوادگی حداقل باید دارای 3 حرف باشد "
}
else {
form.titleFamilyErrorText = ""
}
if (form.addressTitle.length < 3) {
form.titleAddressErrorText = "آدرس حداقل باید دارای 3 حرف باشد "
}
else {
form.titleAddressErrorText = ""
}
const phonepattern = /^09d{9}$/;
if (!phonepattern.test(form.phoneNumber)) {
form.titlePhoneErrorText = "شماره وارد شده صحیح نمی باشد"
}
else {
form.titlePhoneErrorText = "";
}
}
function handlesubmit() {
if (validate()) {
console.log("amir")
router.push({ name: 'map' })
}
}
return { form, validate, handlesubmit }
},
}
submit go to map page and no validate this current page im handle validate page and success form element next page else stay this page
///////////////////