<input type="tel" id="tel">
$("#tel").keyup(function(){ _self = $(this); if(_self.val().length == 3 || _self.val().length == 8){ var str = _self.val()+" "; _self.val(str); } });