Home >Web Front-end >HTML Tutorial >How to use regular expressions to limit the input of text boxes_html/css_WEB-ITnose
What should I do if I want to restrict the input of specific numbers, such as only 0 and 1?
71d8e911276bfdc8c63daaba723aa016How 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 = ''; }}