4

Creating a form with no values and would like the input field to default to empty for two reasons:

  1. Want users to be able to see the placeholder text.
  2. Having a default number means the users can ignore the field by default. (I know I can validate the field, but that is just a bad user experience.)

The problem:

el-input-number fields default to a number (0 or whatever the :min value is set to).

  1. This covers up the placeholder text.
  2. The users can click save with the default number still in place. (I will validate, but don't want users to have to submit a bad value to know what to do.)

Does anyone know how to make the input field have the default value be just empty?

2
  • Have you tried setting your v-model to null ? Commented Jun 29, 2020 at 8:26
  • Unfortunately, null defaults the value to 0 or the :min value. Commented Jul 2, 2020 at 2:50

1 Answer 1

6

just give it a default value of undefined

https://codepen.io/rugia/pen/bGEoWaB?editors=1010

Sign up to request clarification or add additional context in comments.

2 Comments

That solved it. What an obvious solution to try... in hindsight. Thanks!
This short answer helped a lot, but it feels weird where null defaults to 0 and undefined defaults to null. And this behavior is not documented at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.