M
M
myskypesla2018-07-16 15:23:34
JavaScript
myskypesla, 2018-07-16 15:23:34

How to cut phone characters?

I am using the v-mask library.
This is the code for input

input(
        v-model='phone',
        v-mask="'+7 (###) ###-##-##'",
        type='text',
        placeholder='+7 (913) 888-88-88'
      )

and here is the code to remove the characters "+7", ")", " ", "-"
let phone = this.phone.slice('4').split('');
      phone = phone.filter((item) => {
        if (item !== ')' && item !== ' ' && item !== '-') {
          return item;
        }
        return false;
      });
      phone = phone.join('');
      const data = {
        phone,
        password: this.password,
      };

Those. a number comes in this format +7 (999) 999-99-99
And it should leave in this format 9999999999
Is everything right? Or is there some way to make it easier with a plugin or vue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2018-07-16
@myskypesla

const data = {
  phone: this.phone.replace(/\D/g, ''),
  password: this.password,
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question