Javascript String formatPhone()

Description

Javascript String formatPhone()

String.prototype.formatPhone = function () {
    var re = /\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})/g;
    var subst = '$1-$2-$3';
    return this.replace(re, subst);
};



PreviousNext

Related