<script>
const hypenTel = (target) => {
target.value = target.value
.replace(/[^0-9]/g, '')
.replace(/^(\d{2,3})(\d{3,4})(\d{4})$/, `$1-$2-$3`);
}
</script>
<h2>전화번호 변환</h2>
<input type="text" oninput="hypenTel(this)" maxlength="13">
이렇게 해야 연락처 입력 형식을 통일할 수 있다!