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

181
Views
how can i make a readonly field when edited

I'm new to vue.js. I want username to be readonly when user wants to edit his record. But it should not be readonly when first registering. Where am I doing wrong, or what should I add ?

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming you have a property (or computed, or data) which holds the information on whether the user is currently editing their profile (let's name it isEditingProfile), just provide it to input's :readonly, like so:

new Vue({
  el: '#app',
  data: () => ({
    isEditingProfile: false,
    username: ''
  })
})
<script src="https://v2.vuejs.org/js/vue.min.js"></script>
<div id="app">
  <input v-model="username" :readonly="isEditingProfile">
  
  <label>
    <input type="checkbox" v-model="isEditingProfile"> Is editing profile 
  </label>
</div>

Note: I've made isEditingProfile editable here to showcase it's working. In your app, link it to whatever logic should control it. Most probably, you need a computed for it.

about 4 years ago · Juan Pablo Isaza Report
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!