JSFiddle - React, Tailwind, and code Playground

JavaScript

function telephoneCheck(str) {
  var pattern=/((^1((\s\d)|(\s\(\d)|(\d)|(\(\d)))|(^\(\d|^\d))\d{2}((\)\s)|(\)-)|-|\s|\))\d{3}[\s-]\d{4}$|^\d{10}$/;
  if (pattern.exec(str))
  {return true;}
  else {return false;}
}



telephoneCheck("1 555-555-5555");