JSFiddle - React, Tailwind, and code Playground
by Raj Shekhar
HTML
<input class="input" maxlength="10" id="text" type="text" autocomplete="off" />
JavaScript
var text = document.getElementById('text');
text.onkeypress = checkInput
text.onpaste = checkInput;
let regx = /^[6-9]$/;
function checkInput(e) {
var e = e || event,
char = e.type == 'keypress'
? String.fromCharCode(e.keyCode || e.which)
: (e.clipboardData || window.clipboardData).getData('Text');
if(text.value == '' && !regx.test(e.key)){
e.preventDefault();
return false;
}
if (/^[0-9]$/.test(char)) {
}else{
return false;
}
}