How can I prevent letters inside a text element?

html, safari, textinput

Solution

You can use jQuery.

$("#myField").keyup(function() {
    $("#myField").val(this.value.match(/[0-9]*/));
});

Problem

I like to have an input with maximum length 3. These input value should be only numbers no letters. By referring to this post: why is <input type="number" maxlength="3"> not working in Safari? you can see that I can't use `<input type="numbers">` So how can I prevent letters inside an text-input-element?

Original source

Related problems