JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="forTel">
    
    <button id="clicked">check for digits</button>

JavaScript

document.getElementById("clicked").addEventListener("click", function() {
    var tel = document.getElementById("forTel").value;
    var regularExpression = /\d{10}/g;
    (tel.match(regularExpression)) ? alert("All digits!") : alert("Not Digits!");
});