JSFiddle - React, Tailwind, and code Playground
HTML
<input type=tel name=contact[phone] id=phone required pattern=^\d+$>
JavaScript
var input = document.getElementsByName('contact[phone]')[0];
input.addEventListener('change', function() {
console.log('Is valid?', input.value.search(new RegExp(input.getAttribute('pattern'))) !== -1);
}, false);