JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" class="nzPhoneNumber" />

JavaScript

var newFoo = '';
$('.nzPhoneNumber').on('change keydown paste input', function(){
  var foo = $(this).val();
  if (foo.length === 2) {
    newFoo = foo.concat('-')
    $(this).val(newFoo);
  } else if (foo.length === 7) {
  	newFoo = newFoo + foo.substring(3,7) + '-'
    $(this).val(newFoo);
  } else if (foo.length === 15) {
  	newFoo = newFoo + foo.substring(8,15) + '-'
    $(this).val(newFoo);
  }
});


/*
12-3456-7891234-00000
After the 2nd digit/character
After the 6th digit/character
After the 13th digit/character
*/