Skip to content

Instantly share code, notes, and snippets.

@DawTaylor
Created June 13, 2017 13:49
Show Gist options
  • Save DawTaylor/aa30458940627e02b5cca879b9a0baae to your computer and use it in GitHub Desktop.
Save DawTaylor/aa30458940627e02b5cca879b9a0baae to your computer and use it in GitHub Desktop.
Dynamically binds a mask for optional brazilian cell phone number
<template lang="pug>
form
input(type=text)(v-model=celphone)(v-mask=celphoneMask)
</template>
<script>
export default {
name: 'mycomponent',
data() {
return {
celphone: '',
celphoheMask: '(##) ####-####?#'
}
},
watch: {
celphone: function() {
if(this.celphone.length > 14) {
this.mask = '(##) #####-####'
} else {
this.mask = '(##) ####-####?#
}
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment