<p>HTML INPUT只能输入数字</p><pre class="brush:html;toolbar:false">限制HTML的input只能输入数字代码为: &lt;inputid=&quot;amount&quot;style=&quot;IME-MODE:disabled;WIDTH:60px;HEIGHT:15px&quot;onkeyup=&quot;this.value=this.value.replace(/\D/g,&#39;&#39;)&quot;onafterpaste=&quot;this.value=this.value.replace(/\D/g,&#39;&#39;)&quot;maxlength=&quot;5&quot;size=&quot;14&quot;name=&quot;amount&quot;type=&quot;text&quot;/&gt; 限制HTML的input只能输入数字和英文的代码为: &lt;inputonkeyup=&quot;value=value.replace(/[/W]/g,&#39;&#39;)onbeforepaste=&quot;clipboardData.setData(&#39;text&#39;,clipboardData.getData(&#39;text&#39;).replace(/[^/d]/g,&#39;&#39;))&quot;ID=&quot;Text1&quot;NAME=&quot;Text1&quot;&gt; 限制HTML的input只能输入全角的代码为: &lt;inputonkeyup=&quot;value=value.replace(/[^/uFF00-/uFFFF]/g,&#39;&#39;)&quot;onbeforepaste=&quot;clipboardData.setData(&#39;text&#39;,clipboardData.getData(&#39;text&#39;).replace(/[^/uFF00-/uFFFF]/g,&#39;&#39;))&quot;ID=&quot;Text3&quot;NAME=&quot;Text3&quot;&gt; 限制HTML的input只能输入汉字的代码为: &lt;inputonkeyup=&quot;value=value.replace(/[^/u4E00-/u9FA5]/g,&#39;&#39;)&quot;onbeforepaste=&quot;clipboardData.setData(&#39;text&#39;,clipboardData.getData(&#39;text&#39;).replace(/[^/u4E00-/u9FA5]/g,&#39;&#39;))&quot;ID=&quot;Text4&quot;NAME=&quot;Text4&quot;&gt;</pre>
T:0.029582s,M:245.54 KB
返回顶部 留言