数字输入。的HTML [英] Number input. HTML
本文介绍了数字输入。的HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建数字输入,使用户只能输入由五位数字组成的数字?我尝试了此操作,但用户仍然可以输入他/她想要的数字。
How can I create the number input in which user will be able to type only numbers which consist of five digits? I tried this but user still can type as many digits as he/she wants.
<input type="number" placeholder="1" min="1" max="99999">
在我的项目中没有机会使用JavaScript。
There is no opportunity to use JavaScript in my project.
推荐答案
您可以尝试以下操作:
<input name="somename"
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
type = "number"
maxlength = "5"
/>
这篇关于数字输入。的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文