Disable Text Entry in <input type=“number”>
问题 I am making a simple web app. At one part of it, I have included an input box of type="number" <input type="number" min="0"> Anyhow, when I run the code in my latest Google Chrome Browser, I am able to enter text too: I do not want users to be able to do that. How should I rectify this? 回答1: You can use JavaScript (e.g. with jQuery) to allow only specific characters: // Catch all events related to changes $('#textbox').on('change keyup', function() { // Remove invalid characters var sanitized