<! DOCTYPE html>
<body> <form class= "form-horizontal" style= "margin-top:100px;" > <div class= "Form-group" > <label>PHONE</label> <input type= "Tel" class= "Userphone" onkeyup= " This.blur (); This.focus (); "Maxlength=" id= "" placeholder= "Phone" > </div> </form>
<script type= "Text/javascript" > var inputs = Document.queryselector ('. Userphone '); var oninput = onchange | | Oninput; Inputs.oninput = function () {var str = inputs.value; str = formatnum (str.replace (/\d/g, '), true); inputs.value = str;}
function formatnum (num, Istel, count) {Istel = Istel | | 0; count = Count | | 4;
if (istel) {num = ' 0 ' + num;}
var Patt = new RegExp (' \\d{' + Count + '} ', ' g ') num = num.replace (Patt, function ($) {return + + ';})
if (istel) {num = Num.slice (1). Trim ()} return num; } </script></body>
Enter phone number auto-separate