How to disable input text in input field?

There is a field input. How to make box you can enter only numbers? Know that you can mask, but I don't need to make a limit on the number of input digits not to do a mask of the placeholder when you click on the field itself.

How to solve this problem in pure js without jquery? Thank you all for the answers
April 7th 20 at 10:57
4 answers
April 7th 20 at 10:59
April 7th 20 at 11:01
April 7th 20 at 11:03
the <script>
$(document).ready(function() {
$('[name=phone]').bind("change keyup input click", function() { // Specify the field name where you want to deny the contents of the text box
if (this.value.match(/[^0-9]/g)) {
this.value = this.value.replace(/[^0-9]/g, ");
}
});
});
</script>
like writing without jq - Reese_Bahringer commented on April 7th 20 at 11:06
why do we need such a crutch? - Santos commented on April 7th 20 at 11:09
April 7th 20 at 11:05
<input type="number" pattern="[0-9]+">

Find more questions by tags JavaScriptHTML