The title says it all.
How can I make an input accept only numbers from 4-10 and the letter M and nothing else?
Thank you
You can use HTML5 validation. The pattern
attribute lets you specify a regular expression the value of the input must match:
<input pattern="[4-9]|10|M"
title="Enter a number between ‘4’ and ‘10’, or the character ‘M’"
/>
Question already answered, follow the link, the answer there has HTML 5, JavaScript, JQuery, and more solutions. But as the answer states, don't forget to do a server side solution, because the JavaScript might be trespassed or deactivated, and the HTML5 might not work in old browsers. Don't trust user input, re-verify in server side. HTML Text Input allow only Numeric input