What should I do if I want to restrict the input of specific numbers, such as only 0 and 1?
How to restrict it
<input type="text" name="text" id="demo" /><script type="text/javascript">document.getElementById('demo').onchange = function() { if (!/^[01]+$/.test(this.value)) { alert('非法字符'); this.value = ''; }}