Skip to content

No documentation on how to use custom tokens with directive #48

@Vlaoff

Description

@Vlaoff

Hi

I could not find how to use custom tokens with the directive.

Edit: Watching how its done in the component I figured it out, but adding it to the documentation could save time to others in the future.

You just need to pass an object to the v-mask

<input type="tel" v-mask="{mask: '+7 (F##) ###-##-##', tokens: hexTokens}" v-model="phone"/>

You could also define it as an object

data () {
    customMask: {
      mask: '+7 (F##) ###-##-##',
      tokens: 
        'F': {
          pattern: /(?!8)\d/
        },
        '#': {pattern: /\d/}
      }
    }
  }
<input type="tel" v-mask="customMask" v-model="phone"/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions