RonaldJerez / vue-input-facade

A lightweight and dependency free input masking library created specific for Vue
https://ronaldjerez.github.io/vue-input-facade/latest/
182 stars 27 forks source link

Accessing the unmasked value in vuetify #12

Closed cdsim closed 4 years ago

cdsim commented 4 years ago

Hi, Im trying out vue-input-facade in vuetify and I can't seem to be able to get the unmasked value from a <v-text-field>.

<v-text-field
  v-model="value"
  v-mask="'##.##.##'"
  @input="logValue"
  hide-details
></v-text-field>
...
methods: {
  logValue(event) {
    console.log(event);    // 12.34.56
  }
}

The value is always masked, is there anyway we can access the unmasked value?

vuetify-2.2.28, I tried vue-input-facade-1.1.15 & latest v1.2.0-beta.4

Updated the code to include the input event.

RonaldJerez commented 4 years ago

Since you are using the directive you’ll have to access the unmasked value using the input event.

See “acceding the unmasked value” in the demo page

cdsim commented 4 years ago

Yes I did try that, but the value returned by the input event is still masked, the event does not return the unmasked value. It's only with Vuetify tho, when I use an input tag I get the unmasked value.

RonaldJerez commented 4 years ago

I see what you mean, looks like vuetify is not passing the native event to the handler. You can always use v-on:input.native and you'll receive the native event.

@input.native="handler" - you'll get the whole event object @input.native="handler($event.target.unmaskedValue)" - you'll get the value as a string

cdsim commented 4 years ago

Ah yup, it does work with the native event, I get access to the unmasked property this way. Thank you !