Advertisement
rstx2

NPWP Formatting

Nov 24th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <div id="coba">
  2. <input class="form-control" v-model="form.npwp" v-validate="'required'" name="npwp" type="text" @input="acceptNumber" required>
  3. <div v-show="errors.has('npwp')" class="form-control-feedback">{{ errors.first('npwp') }}</div>
  4.  
  5. </div>
  6.  
  7. methods: {
  8. acceptNumber() {
  9. var x = this.form.npwp.replace(/\D/g, '').match(/(\d{0,2})(\d{0,3})(\d{0,3})(\d{0,1})(\d{0,3})(\d{0,3})/)
  10. this.form.npwp = !x[2] ? x[1] : x[1] + '.' + x[2] +
  11. (x[3] ? '.' + x[3] + (x[4] ? '.' + x[4] + (x[5] ? '-' + x[5] + (x[6] ? '.' + x[6] : '') : '') : '') : '')
  12. }
  13. },
  14.  
  15. mounted() {
  16. let externalScript = document.createElement('script')
  17. externalScript.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js')
  18. document.head.appendChild(externalScript)
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement