Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
Checkbox validation and rerouting in VUE.js

I am trying to validate the check box and navigate to next link for ex google.com. I found the solution for checkbox validation from the below link Vue JS - Checkbox validation error on submit from @wolfrevo

new Vue({
 el: "#app",
 data: {
 termsState: false,
 validated: false,
 nextPageUrl:'www.google.com'
  },
computed: {
  termsError() {
   return this.validated && !this.termsState
  }
},
methods: {
  handleTermsState() {
  this.validated = false
},

handleSubmit() {
  this.validated = true
}
}
  })

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id='app'>
<label for="terms">
        Terms and Privacy Policy
        <input type="checkbox" id="terms" name="terms" v-model="termsState"    @change="handleTermsState">
        {{ termsState }}
    </label>
  <p style="color: red" class="for-error terms-error" v-if="termsError">You have to agree the terms and privacy condition.</p>
  <router-link :to="nextPageUrl">
      <div><button type="submit" @click="handleSubmit">Submit</button></div>
  </router-link>
</div>

I tried adding router-link, it is redirecting even without validating the checkbox. what is that I am missing?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!