$('input').on('input', function() {
this.value = this.value.replace(/^0|[^\d]/g, ");
})
const input = document.querySelector(".input");
input.addEventListener("input", (event) => {
event.target.value = event.target.value.replace(/^0|[^\d]/g, ");
});
/^0|\D/g
Find more questions by tags Regular expressionsJavaScript
if it starts with 0 or begins with any numeric character, replaced by "
But why replace only 0 ? - Julio.Erdma commented on April 19th 20 at 12:43
[^\d]
is "netira". I.e., this expression will kill characters, spaces, etc. - hellen5 commented on April 19th 20 at 12:49