I am developing a Nuxtjs application and in that, I have a form, the user fills in the information and submits the form. After submission user is navigated to a different route. Now if the user clicks on the back button of browser then the user has navigated to form again but the data are reset in the field.
I want to ensure that when the user clicks on the browser back button then the data which was filled in by the user to be retained. I tried searching and found that we need to use autocomplete=on and I tried that but it's not working for me. Can someone please help me with how can I retain the user-provided information inform when the user navigates back to the route.
<template>
<div id="eventForm" class="row" style="margin-top:1%">
<form ref="testDataForm" class="form-horizontal" autocomplete="on" @submit.prevent="formSubmit">
<input
v-model="formData.eventCount"
type="number"
class="form-control"
required
>
<b-form-select v-model="formData.optionsSelector" class="form-control">
<b-form-select-option value="null" disabled selected>
Choose
</b-form-select-option>
<b-form-select-option value="value1">
Text1
</b-form-select-option>
<b-form-select-option value="value2">
Text2
</b-form-select-option>
</b-form-select>
<button type="submit" class="btn btn-success">
Submit
</button>
</form>
</div>
</template>
<script>
export default {
data () {
return {
formData: {
optionsSelector: null
}
}
},
methods: {
formSubmit () {
this.$router.push('/GenerateTestData')
// this.$router.push({ path: '/GenerateTestData' })
}
}
}
</script>
<style>
</style>