I am working on JavaScript regular expressions and as per my need text box accept only 10 digit numbers but string and special character are not allowed I tried this it but didn't work for me.
function myFunction() {
  var number = $("#num").val();
  var compare = '[0][1-9]\d{9}$|^[1-9]\d{9}$';
  if (number.match(compare)) {
    return true;
  } else {
    alert('not match');
    return false;
  }
}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="num" onblur="myFunction()"> 
     
     
     
     
    