v-money icon indicating copy to clipboard operation
v-money copied to clipboard

Placeholder option?

Open mcrider opened this issue 6 years ago • 11 comments

Is it possible to use placeholder text instead inside the input of just displaying the default model value?

mcrider avatar Apr 19 '18 15:04 mcrider

+1, would love to know this as well. I have a requirement from a client where they want to not show a default value - v-money will always force a value of 0. I don't want to mask unless the user has input something.

DinsmoreDesign avatar May 07 '18 18:05 DinsmoreDesign

+2000

matthew-socialcore avatar May 16 '18 18:05 matthew-socialcore

This will be interesting for me as well, +1.

fergardi avatar May 21 '18 07:05 fergardi

+1. I would love this option too. At the moment, showing 0.00 is confusing to my customers as they think the price is zero as opposed to been not set

breaktag avatar Jun 13 '18 21:06 breaktag

+1 would love too...

xerminada avatar Jul 23 '18 22:07 xerminada

You can show the input placeholder using the v-money directive instead of the component.

<input placeholder="00.00" v-model="price" v-money="price !== null ? money : null" class="form-input input-lg" />

Fiddle adapted from the read.me: https://jsfiddle.net/fnxub0yg/1/

yvdlima avatar Nov 20 '18 04:11 yvdlima

@yvdlima Actually I want to get unmasked value. Then I cannot use the directive. So I should use the component, but the component cannot accept null.

mrsweetie-k avatar Dec 04 '18 03:12 mrsweetie-k

@kimyeongbin As a workaround you could remove the mask manually:

<input v-money="money" @change="uglyWorkaround" model="maskedValue">

methods: {
  uglyWorkaround() {
    this.value = parseFloat(this.maskedValue.replace(".", "").replace(",", "."));
    // Do it where it makes sense for your case, not necessary on change event
  }
}

yvdlima avatar Dec 04 '18 05:12 yvdlima

@yvdlima ~~How about changing the value prop of the component to allow null ? I don't know the side effect of it, but I simply think that's the best way without doing ugly things.~~

I find this fork. I'm using the allowBlank option and it can be solved. nholden/v-money

https://github.com/vuejs-tips/v-money/pull/51 https://github.com/nholden/v-money

mrsweetie-k avatar Dec 04 '18 06:12 mrsweetie-k

You can show the input placeholder using the v-money directive instead of the component.

<input placeholder="00.00" v-model="price" v-money="price !== null ? money : null" class="form-input input-lg" />

Fiddle adapted from the read.me: https://jsfiddle.net/fnxub0yg/1/

Thanks! It's cool!

evgeniyGusev avatar Aug 23 '21 08:08 evgeniyGusev

hey, Unfortunately I don't think support will come soon. This repo seems to be abandoned! I decided to upgrade this package to be used with Vue3.

Welcome v-money3!

I'm interested to maintain v-money3 for vue 3 and beyond. Feel free to open this same issue there if you are planning to upgrade your project.

jonathanpmartins avatar Aug 28 '21 03:08 jonathanpmartins