1

I have an input field set up as

<input @input="e => machineCIDR = e.target.value" type="text" name="machine" class="form-control form-control-lg" :placeholder="machineCIDR">

The problem is, whenever someone fills out the form and then deletes it all, the placeholder is left with the last character that was filled out.

How can I setup :placeholder="machineCIDR" so that it shows the initial value, and then never gets updated again??

Will Gordon
  • 3,303
  • 2
  • 11
  • 22

1 Answers1

0

Assuming machineCIDR is set up already (as a prop or in data), you could create an object for storing all of your initial values:

data() {
  return {
    ...
    initial: {}
  }
}

And set up the values in created:

created() {
  this.initial['machineCIDR'] = this.machineCIDR;
}

Then bind to that instead in the placeholder:

:placeholder="initial['machineCIDR']"
Dan
  • 59,490
  • 13
  • 101
  • 110