Skip to content

[Feature request] Clear input on focus when value is zero #26

Closed
@ankurk91

Description

@ankurk91

Hi,

When current value is zero 0.00 and user focus on input, user has to remove this value by pressing backspace 4 times and then he can start typing new values.
It would be good if component can clear the input field automatically when value is zero.

I made a simple directive to achieve this.

Vue.directive('clear-zero', {
  bind: function (el, binding, vnode) {
    el.onfocus = function () {
      if (parseFloat(el.value) === 0) {
        console.log('Clear value');
        el.value = null;
      }
    };
  }
});
<vue-numeric v-clear-zero currency="$" :precision="2" v-model="amount ></vue-numeric>

Current behavior
vue-numeric-issue
Expected behavior (with directive)
directive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions