JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/imask"></script>
<p>ex.1
<input id="foo" placeholder="最初の文字のみ1~6、それ以降は数字、全部で6文字まで">
</p>
<p>ex.2
<input id="bar" placeholder="でんわばんごう">
</p>
CSS
input{width:75%;padding:15px;}
JavaScript
var regExpMask = new IMask(
document.getElementById('foo'),
{
mask: /^[1-6]\d{0,5}$/
});
var phoneMask = new IMask(
document.getElementById('bar'), {
mask: '+{81}(00)0000-0000'
});