Calculation to Change Numbers to a Phone Number Format

Comments

1 comment

  • Rainer Grabowski

    Hi Joshua,

    this is the code if @Phone Number 3 is a text field. 

    var phone = @Phone Number 3;
    var cleanPhone = phone.replace(/[^0-9]/g,"");
    cleanPhone.replace(/(\d{3})(\d{3})(\d{4})/,"($1)-$2-$3")

    If it is a Phone field:

    var phone = @Phone Number 3;
    var phone = phone.map(function (i){return i.value}).join();
    var cleanPhone = phone.replace(/[^0-9]/g,"");
    cleanPhone.replace(/(\d{3})(\d{3})(\d{4})/,"($1)-$2-$3")

    Rainer

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk