Make a user input phone number display as (xxx) xxx-xxxx on entry.

It seems like you solved it, yet try this, or to anyone trying to do something similar:

$w.onReady(function () {

 const locale = ("en-US");

$w("#dynamicDataset").onReady(() => {

 let itemObj = $w("#dynamicDataset").getCurrentItem();

   $w("#textElement").text = itemObj.fieldKey.toLocaleString(locale);
  }
 
});
 
});

Basically, this returns the string based on a language. Use your dataset name, text element, and the fieldKey that holds the number. The benefit? You can make it work with dates, time, and it is pretty straight forward.