jQuery Telefon Formatı

jQuery Input Mask Phone Format
CDN:
https://cdnjs.com/libraries/jquery.mask

$(“#phone”).mask(“(999) 999-99-99”);
$(“#phone”).on(“blur”, function() {
var last = $(this).val().substr( $(this).val().indexOf(“-“) + 1 );

if( last.length == 3 ) {
var move = $(this).val().substr( $(this).val().indexOf(“-“) – 1, 1 );
var lastfour = move + last;
var first = $(this).val().substr( 0, 9 );
$(this).val( first + ‘-‘ + lastfour );
}
});